{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "# !pip install --quiet --upgrade langchain-community langchain-experimental langchain-openai neo4j graphdatascience tiktoken retry"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/workspaces/llm-graph-builder/chatbotenv/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
      "  from .autonotebook import tqdm as notebook_tqdm\n"
     ]
    }
   ],
   "source": [
    "import getpass\n",
    "import os\n",
    "from langchain_community.graphs import Neo4jGraph\n",
    "from graphdatascience import GraphDataScience\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "from langchain_core.prompts import ChatPromptTemplate\n",
    "from langchain_core.output_parsers import StrOutputParser\n",
    "from src.llm import get_llm\n",
    "\n",
    "import os\n",
    "import getpass\n",
    "from neo4j import GraphDatabase, Result\n",
    "import pandas as pd\n",
    "import seaborn as sns\n",
    "import matplotlib.pyplot as plt\n",
    "import tiktoken\n",
    "import numpy as np\n",
    "from langchain_openai import OpenAIEmbeddings, ChatOpenAI\n",
    "from langchain_community.vectorstores import Neo4jVector\n",
    "from langchain_community.graphs import Neo4jGraph\n",
    "from langchain_core.prompts import ChatPromptTemplate\n",
    "from langchain_core.output_parsers import StrOutputParser\n",
    "# from llama_index.core.schema import TextNode\n",
    "# from llama_index.core.vector_stores.utils import node_to_metadata_dict\n",
    "# from llama_index.vector_stores.neo4jvector import Neo4jVectorStore\n",
    "# from llama_index.core import VectorStoreIndex\n",
    "from tqdm import tqdm\n",
    "from src.shared.common_fn import load_embedding_model\n",
    "\n",
    "\n",
    "from typing import Dict, Any\n",
    "from concurrent.futures import ThreadPoolExecutor, as_completed\n",
    "from tqdm import tqdm\n",
    "from src.llm import get_llm"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "os.environ[\"NEO4J_URI\"] = \"\"\n",
    "os.environ[\"NEO4J_USERNAME\"] = \"neo4j\"\n",
    "os.environ[\"NEO4J_PASSWORD\"] = \"\"\n",
    "os.environ[\"OPENAI_API_KEY\"] = \"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Received notification from DBMS server: {severity: WARNING} {code: Neo.ClientNotification.Statement.FeatureDeprecationWarning} {category: DEPRECATION} {title: This feature is deprecated and will be removed in future versions.} {description: The query used a deprecated field from a procedure. ('advertisedListenAddress' returned by 'gds.debug.arrow' is deprecated.)} {position: line: 1, column: 1, offset: 0} for query: 'CALL gds.debug.arrow()'\n",
      "Received notification from DBMS server: {severity: WARNING} {code: Neo.ClientNotification.Statement.FeatureDeprecationWarning} {category: DEPRECATION} {title: This feature is deprecated and will be removed in future versions.} {description: The query used a deprecated field from a procedure. ('serverLocation' returned by 'gds.debug.arrow' is deprecated.)} {position: line: 1, column: 1, offset: 0} for query: 'CALL gds.debug.arrow()'\n"
     ]
    }
   ],
   "source": [
    "gds = GraphDataScience(\n",
    "    os.environ[\"NEO4J_URI\"],\n",
    "    auth=(os.environ[\"NEO4J_USERNAME\"], os.environ[\"NEO4J_PASSWORD\"])\n",
    ")\n",
    "\n",
    "graph = Neo4jGraph() \n",
    "\n",
    "driver = GraphDatabase.driver(os.environ[\"NEO4J_URI\"], auth=(os.environ[\"NEO4J_USERNAME\"], os.environ[\"NEO4J_PASSWORD\"]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{'type': 'node', 'total_count': 185, 'non_null_descriptions': 146},\n",
       " {'type': 'relationship', 'total_count': 14614, 'non_null_descriptions': 41}]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "graph.query(\"\"\"\n",
    "MATCH (n:`__Entity__`)\n",
    "RETURN \"node\" AS type,\n",
    "       count(*) AS total_count,\n",
    "       count(n.description) AS non_null_descriptions\n",
    "UNION ALL\n",
    "MATCH (n)-[r:!MENTIONS]->()\n",
    "RETURN \"relationship\" AS type,\n",
    "       count(*) AS total_count,\n",
    "       count(r.description) AS non_null_descriptions\n",
    "\"\"\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Received notification from DBMS server: {severity: WARNING} {code: Neo.ClientNotification.Statement.FeatureDeprecationWarning} {category: DEPRECATION} {title: This feature is deprecated and will be removed in future versions.} {description: The query used a deprecated field from a procedure. ('schema' returned by 'gds.graph.list' is deprecated.)} {position: line: 1, column: 1, offset: 0} for query: 'CALL gds.graph.list()'\n"
     ]
    }
   ],
   "source": [
    "available_graphs = gds.graph.list()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "available_graphs.drop([0,1],inplace=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>degreeDistribution</th>\n",
       "      <th>graphName</th>\n",
       "      <th>database</th>\n",
       "      <th>databaseLocation</th>\n",
       "      <th>memoryUsage</th>\n",
       "      <th>sizeInBytes</th>\n",
       "      <th>nodeCount</th>\n",
       "      <th>relationshipCount</th>\n",
       "      <th>configuration</th>\n",
       "      <th>density</th>\n",
       "      <th>creationTime</th>\n",
       "      <th>modificationTime</th>\n",
       "      <th>schema</th>\n",
       "      <th>schemaWithOrientation</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [degreeDistribution, graphName, database, databaseLocation, memoryUsage, sizeInBytes, nodeCount, relationshipCount, configuration, density, creationTime, modificationTime, schema, schemaWithOrientation]\n",
       "Index: []"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "available_graphs"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "available_graphs[\"graphName\"].str.contains('communities', regex=False).any()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Received notification from DBMS server: {severity: WARNING} {code: Neo.ClientNotification.Statement.FeatureDeprecationWarning} {category: DEPRECATION} {title: This feature is deprecated and will be removed in future versions.} {description: The query used a deprecated field from a procedure. ('schema' returned by 'gds.graph.drop' is deprecated.)} {position: line: 1, column: 1, offset: 0} for query: 'CALL gds.graph.drop($graph_name, $fail_if_missing, $db_name)'\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "graphName                                                      communities\n",
       "database                                                             neo4j\n",
       "databaseLocation                                                     local\n",
       "memoryUsage                                                               \n",
       "sizeInBytes                                                             -1\n",
       "nodeCount                                                              185\n",
       "relationshipCount                                                      366\n",
       "configuration            {'relationshipProjection': {'_ALL_': {'aggrega...\n",
       "density                                                           0.010752\n",
       "creationTime                           2024-08-19T12:41:43.997435629+00:00\n",
       "modificationTime                       2024-08-19T12:41:44.127124307+00:00\n",
       "schema                   {'graphProperties': {}, 'nodes': {'__Entity__'...\n",
       "schemaWithOrientation    {'graphProperties': {}, 'nodes': {'__Entity__'...\n",
       "Name: 0, dtype: object"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "gds.graph.drop(\"communities\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "G, result = gds.graph.project(\n",
    "    \"communities\",  #  Graph name\n",
    "    \"__Entity__\",  #  Node projection\n",
    "    {\n",
    "        \"_ALL_\": {\n",
    "            \"type\": \"*\",\n",
    "            \"orientation\": \"UNDIRECTED\",\n",
    "            \"properties\": {\"weight\": {\"property\": \"*\", \"aggregation\": \"COUNT\"}},\n",
    "        }\n",
    "    },\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "nodeProjection            {'__Entity__': {'label': '__Entity__', 'proper...\n",
       "relationshipProjection    {'_ALL_': {'aggregation': 'DEFAULT', 'orientat...\n",
       "graphName                                                       communities\n",
       "nodeCount                                                               185\n",
       "relationshipCount                                                       366\n",
       "projectMillis                                                            15\n",
       "Name: 0, dtype: object"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Received notification from DBMS server: {severity: WARNING} {code: Neo.ClientNotification.Statement.FeatureDeprecationWarning} {category: DEPRECATION} {title: This feature is deprecated and will be removed in future versions.} {description: The query used a deprecated field from a procedure. ('schema' returned by 'gds.graph.list' is deprecated.)} {position: line: 1, column: 106, offset: 105} for query: 'CALL gds.graph.list($graph_name) YIELD graphName, nodeCount, relationshipCount, database, configuration, schema, memoryUsage'\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "Graph({'graphName': 'communities', 'nodeCount': 185, 'relationshipCount': 366, 'database': 'neo4j', 'configuration': {'relationshipProjection': {'_ALL_': {'aggregation': 'DEFAULT', 'orientation': 'UNDIRECTED', 'indexInverse': False, 'properties': {'weight': {'aggregation': 'COUNT', 'property': '*', 'defaultValue': None}}, 'type': '*'}}, 'readConcurrency': 4, 'relationshipProperties': {}, 'nodeProperties': {}, 'jobId': 'ced0b057-a717-48d8-8b90-842f6f2aa001', 'nodeProjection': {'__Entity__': {'label': '__Entity__', 'properties': {}}}, 'logProgress': True, 'creationTime': neo4j.time.DateTime(2024, 8, 19, 13, 10, 3, 641071700, tzinfo=<UTC>), 'validateRelationships': False, 'sudo': False}, 'schema': {'graphProperties': {}, 'nodes': {'__Entity__': {}}, 'relationships': {'_ALL_': {'weight': 'Float (DefaultValue(NaN), PERSISTENT, Aggregation.COUNT)'}}}, 'memoryUsage': '2316 KiB'})"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "G"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'COMMUNITY_PROJECT_NAME'"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\"community_project_name\".upper()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Component count: 14\n",
      "Component distribution: {'min': 1, 'p5': 1, 'max': 155, 'p999': 155, 'p99': 155, 'p1': 1, 'p10': 1, 'p90': 3, 'p50': 1, 'p25': 1, 'p75': 2, 'p95': 155, 'mean': 12.285714285714286}\n"
     ]
    }
   ],
   "source": [
    "wcc = gds.wcc.stats(G)\n",
    "print(f\"Component count: {wcc['componentCount']}\")\n",
    "print(f\"Component distribution: {wcc['componentDistribution']}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "writeMillis                                                              5\n",
       "nodePropertiesWritten                                                  172\n",
       "ranLevels                                                                2\n",
       "didConverge                                                           True\n",
       "nodeCount                                                              172\n",
       "communityCount                                                          22\n",
       "communityDistribution    {'min': 1, 'p5': 1, 'max': 64, 'p999': 64, 'p9...\n",
       "modularity                                                        0.678705\n",
       "modularities                      [0.6566821889989846, 0.6787052274080039]\n",
       "postProcessingMillis                                                     3\n",
       "preProcessingMillis                                                      0\n",
       "computeMillis                                                           33\n",
       "configuration            {'writeProperty': 'communities', 'theta': 0.01...\n",
       "Name: 0, dtype: object"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "gds.leiden.write(\n",
    "    G,\n",
    "    writeProperty=\"communities\",\n",
    "    includeIntermediateCommunities=True,\n",
    "    relationshipWeightProperty=\"weight\",\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[]"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "graph.query(\"CREATE CONSTRAINT IF NOT EXISTS FOR (c:__Community__) REQUIRE c.id IS UNIQUE;\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{'count(*)': 344}]"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "graph.query(\"\"\"\n",
    "MATCH (e:`__Entity__`)\n",
    "UNWIND range(0, size(e.communities) - 1 , 1) AS index\n",
    "CALL {\n",
    "  WITH e, index\n",
    "  WITH e, index\n",
    "  WHERE index = 0\n",
    "  MERGE (c:`__Community__` {id: toString(index) + '-' + toString(e.communities[index])})\n",
    "  ON CREATE SET c.level = index\n",
    "  MERGE (e)-[:IN_COMMUNITY]->(c)\n",
    "  RETURN count(*) AS count_0\n",
    "}\n",
    "CALL {\n",
    "  WITH e, index\n",
    "  WITH e, index\n",
    "  WHERE index > 0\n",
    "  MERGE (current:`__Community__` {id: toString(index) + '-' + toString(e.communities[index])})\n",
    "  ON CREATE SET current.level = index\n",
    "  MERGE (previous:`__Community__` {id: toString(index - 1) + '-' + toString(e.communities[index - 1])})\n",
    "  ON CREATE SET previous.level = index - 1\n",
    "  MERGE (previous)-[:IN_COMMUNITY]->(current)\n",
    "  RETURN count(*) AS count_1\n",
    "}\n",
    "RETURN count(*)\n",
    "\"\"\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[]"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "graph.query(\"\"\"\n",
    "MATCH (c:__Community__)<-[:IN_COMMUNITY*]-(:__Entity__)<-[:MENTIONS]-(d:Document)\n",
    "WITH c, count(distinct d) AS rank\n",
    "SET c.community_rank = rank;\n",
    "\"\"\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Level</th>\n",
       "      <th>Number of communities</th>\n",
       "      <th>25th Percentile</th>\n",
       "      <th>50th Percentile</th>\n",
       "      <th>75th Percentile</th>\n",
       "      <th>90th Percentile</th>\n",
       "      <th>99th Percentile</th>\n",
       "      <th>Max</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>28</td>\n",
       "      <td>1.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>3.75</td>\n",
       "      <td>13.9</td>\n",
       "      <td>49.66</td>\n",
       "      <td>61</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>22</td>\n",
       "      <td>1.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>8.50</td>\n",
       "      <td>17.8</td>\n",
       "      <td>54.55</td>\n",
       "      <td>64</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  Level  Number of communities  25th Percentile  50th Percentile  \\\n",
       "0     0                     28              1.0              2.0   \n",
       "1     1                     22              1.0              2.0   \n",
       "\n",
       "   75th Percentile  90th Percentile  99th Percentile  Max  \n",
       "0             3.75             13.9            49.66   61  \n",
       "1             8.50             17.8            54.55   64  "
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\n",
    "community_size = graph.query(\n",
    "    \"\"\"\n",
    "MATCH (c:__Community__)<-[:IN_COMMUNITY*]-(e:__Entity__)\n",
    "WITH c, count(distinct e) AS entities\n",
    "RETURN split(c.id, '-')[0] AS level, entities\n",
    "\"\"\"\n",
    ")\n",
    "community_size_df = pd.DataFrame.from_records(community_size)\n",
    "percentiles_data = []\n",
    "for level in community_size_df[\"level\"].unique():\n",
    "    subset = community_size_df[community_size_df[\"level\"] == level][\"entities\"]\n",
    "    num_communities = len(subset)\n",
    "    percentiles = np.percentile(subset, [25, 50, 75, 90, 99])\n",
    "    percentiles_data.append(\n",
    "        [\n",
    "            level,\n",
    "            num_communities,\n",
    "            percentiles[0],\n",
    "            percentiles[1],\n",
    "            percentiles[2],\n",
    "            percentiles[3],\n",
    "            percentiles[4],\n",
    "            max(subset)\n",
    "        ]\n",
    "    )\n",
    "\n",
    "# Create a DataFrame with the percentiles\n",
    "percentiles_df = pd.DataFrame(\n",
    "    percentiles_data,\n",
    "    columns=[\n",
    "        \"Level\",\n",
    "        \"Number of communities\",\n",
    "        \"25th Percentile\",\n",
    "        \"50th Percentile\",\n",
    "        \"75th Percentile\",\n",
    "        \"90th Percentile\",\n",
    "        \"99th Percentile\",\n",
    "        \"Max\"\n",
    "    ],\n",
    ")\n",
    "percentiles_df\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### community summaries"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "community_info = graph.query(\"\"\"\n",
    "MATCH (c:`__Community__`)<-[:IN_COMMUNITY*]-(e:__Entity__)\n",
    "WHERE c.level IN [0,1,4]\n",
    "WITH c, collect(e ) AS nodes\n",
    "WHERE size(nodes) > 1\n",
    "CALL apoc.path.subgraphAll(nodes[0], {\n",
    "\twhitelistNodes:nodes\n",
    "})\n",
    "YIELD relationships\n",
    "RETURN c.id AS communityId,\n",
    "       [n in nodes | {id: n.id, description: n.description, type: [el in labels(n) WHERE el <> '__Entity__'][0]}] AS nodes,\n",
    "       [r in relationships | {start: startNode(r).id, type: type(r), end: endNode(r).id, description: r.description}] AS rels\n",
    "\"\"\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{'communityId': '0-36',\n",
       "  'nodes': [{'id': 'India',\n",
       "    'description': 'Officially the Republic of India, located in South Asia.',\n",
       "    'type': 'Country'},\n",
       "   {'id': 'Supreme Court Of India',\n",
       "    'description': 'Head of the independent judiciary.',\n",
       "    'type': 'Judiciary'},\n",
       "   {'id': 'Indian National Congress',\n",
       "    'description': 'Dominated Indian politics until 1977.',\n",
       "    'type': 'Political party'},\n",
       "   {'id': 'Sindhu',\n",
       "    'description': 'Name of the Indus River, from which the name India is derived.',\n",
       "    'type': 'River'},\n",
       "   {'id': 'Food And Agriculture Organization Of The United Nations',\n",
       "    'description': \"Estimates India's forest cover.\",\n",
       "    'type': 'Organization'},\n",
       "   {'id': '2013 Forest Survey Of India',\n",
       "    'description': \"States India's forest cover increased to 69.8 million hectares by 2012.\",\n",
       "    'type': 'Report'},\n",
       "   {'id': 'Yajnavalkya Smriti',\n",
       "    'description': 'Prohibited the cutting of trees.',\n",
       "    'type': 'Literature'},\n",
       "   {'id': 'Kautalyas Arthashastra',\n",
       "    'description': 'Discusses the need for forest administration.',\n",
       "    'type': 'Literature'},\n",
       "   {'id': 'Crown Land (Encroachment) Ordinance',\n",
       "    'description': \"Promulgated in 1840 targeting forests in Britain's Asian colonies.\",\n",
       "    'type': 'Legislation'},\n",
       "   {'id': 'Indian Forest Act Of 1865',\n",
       "    'description': \"Established the government's claims over forests.\",\n",
       "    'type': 'Legislation'},\n",
       "   {'id': 'Forest Act Of 1878',\n",
       "    'description': 'Gave the British government control over all wastelands, including forests.',\n",
       "    'type': 'Legislation'},\n",
       "   {'id': 'Sir Dietrich Brandis',\n",
       "    'description': 'Inspector General of Forests in India from 1864 to 1883.',\n",
       "    'type': 'Person'},\n",
       "   {'id': 'Indian Ocean',\n",
       "    'description': 'Ocean bounded by India on the north.',\n",
       "    'type': 'Ocean'},\n",
       "   {'id': 'Sri Lanka',\n",
       "    'description': 'Country in the vicinity of India in the Indian Ocean.',\n",
       "    'type': 'Country'},\n",
       "   {'id': 'Maldives',\n",
       "    'description': 'Country in the vicinity of India in the Indian Ocean.',\n",
       "    'type': 'Country'},\n",
       "   {'id': 'Myanmar',\n",
       "    'description': 'Country sharing land border with India to the east.',\n",
       "    'type': 'Country'},\n",
       "   {'id': 'Himalayan Mountain Range',\n",
       "    'description': 'Defines the northern frontiers of India.',\n",
       "    'type': 'Mountain range'},\n",
       "   {'id': 'China',\n",
       "    'description': 'Country sharing land border with India to the north.',\n",
       "    'type': 'Country'},\n",
       "   {'id': 'Bhutan',\n",
       "    'description': 'Country sharing land border with India to the north.',\n",
       "    'type': 'Country'},\n",
       "   {'id': 'Nepal',\n",
       "    'description': 'Country sharing land border with India to the north.',\n",
       "    'type': 'Country'},\n",
       "   {'id': 'Pakistan',\n",
       "    'description': 'Country sharing land border with India to the west.',\n",
       "    'type': 'Country'},\n",
       "   {'id': 'Bangladesh',\n",
       "    'description': 'Country sharing land border with India to the east.',\n",
       "    'type': 'Country'},\n",
       "   {'id': 'Ganges',\n",
       "    'description': 'The longest river originating in India.',\n",
       "    'type': 'River'},\n",
       "   {'id': 'Western Ghats',\n",
       "    'description': 'One of the three biodiversity hotspots in India.',\n",
       "    'type': 'Biodiversity hotspot'},\n",
       "   {'id': 'Eastern Himalayas',\n",
       "    'description': 'One of the three biodiversity hotspots in India.',\n",
       "    'type': 'Biodiversity hotspot'},\n",
       "   {'id': 'Indo-Burma Hotspot',\n",
       "    'description': 'One of the three biodiversity hotspots in India.',\n",
       "    'type': 'Biodiversity hotspot'},\n",
       "   {'id': 'Forests',\n",
       "    'description': 'Covers about 24.6% of the total land area.',\n",
       "    'type': 'Ecosystem'},\n",
       "   {'id': 'Indomalayan Realm',\n",
       "    'description': 'Geographical realm that includes India.',\n",
       "    'type': 'Realm'},\n",
       "   {'id': 'World', 'description': None, 'type': None},\n",
       "   {'id': 'Public_Sector', 'description': None, 'type': None},\n",
       "   {'id': 'Gdp', 'description': None, 'type': None},\n",
       "   {'id': 'Economic_Liberalisation', 'description': None, 'type': None},\n",
       "   {'id': 'Gdp_Growth', 'description': None, 'type': None},\n",
       "   {'id': 'Consumer_Market', 'description': None, 'type': None},\n",
       "   {'id': 'Wto', 'description': None, 'type': None},\n",
       "   {'id': 'Ease_Of_Business_Index', 'description': None, 'type': None},\n",
       "   {'id': 'Global_Competitiveness_Index', 'description': None, 'type': None},\n",
       "   {'id': 'Billionaires', 'description': None, 'type': None},\n",
       "   {'id': 'Welfare_State', 'description': None, 'type': None},\n",
       "   {'id': 'Socialist_State', 'description': None, 'type': None},\n",
       "   {'id': 'Social_Welfare_Spending', 'description': None, 'type': None},\n",
       "   {'id': 'Labour_Force', 'description': None, 'type': None},\n",
       "   {'id': 'Fdi', 'description': None, 'type': None},\n",
       "   {'id': 'Free_Trade_Agreements', 'description': None, 'type': None},\n",
       "   {'id': 'Service_Sector', 'description': None, 'type': None},\n",
       "   {'id': 'Stock_Exchanges', 'description': None, 'type': None},\n",
       "   {'id': 'Manufacturing', 'description': None, 'type': None},\n",
       "   {'id': 'Population', 'description': None, 'type': None},\n",
       "   {'id': 'Unemployment', 'description': None, 'type': None},\n",
       "   {'id': 'Savings_Rate', 'description': None, 'type': None},\n",
       "   {'id': 'Arabian Sea',\n",
       "    'description': 'Sea bounded by India on the northwest.',\n",
       "    'type': 'Sea'},\n",
       "   {'id': 'Bay Of Bengal',\n",
       "    'description': 'Bay bounded by India on the southeast.',\n",
       "    'type': 'Bay'},\n",
       "   {'id': 'Africa',\n",
       "    'description': 'Continent from which modern humans arrived on the Indian subcontinent.',\n",
       "    'type': 'Continent'},\n",
       "   {'id': 'Indus Valley Civilisation',\n",
       "    'description': 'Civilisation that evolved from settled life in the western margins of the Indus river basin.',\n",
       "    'type': 'Civilization'},\n",
       "   {'id': 'Sanskrit',\n",
       "    'description': 'Indo-European language that diffused into India from the northwest.',\n",
       "    'type': 'Language'},\n",
       "   {'id': 'Rigveda',\n",
       "    'description': 'Ancient hymns recording the dawning of Hinduism in India.',\n",
       "    'type': 'Text'},\n",
       "   {'id': 'Hinduism',\n",
       "    'description': 'Major religion in India, with roots in the Rigveda.',\n",
       "    'type': 'Religion'},\n",
       "   {'id': 'Buddhism',\n",
       "    'description': 'Religion that arose in India, proclaiming social orders unlinked to heredity.',\n",
       "    'type': 'Religion'},\n",
       "   {'id': 'Jainism',\n",
       "    'description': 'Religion that arose in India, proclaiming social orders unlinked to heredity.',\n",
       "    'type': 'Religion'},\n",
       "   {'id': 'Mughal Empire',\n",
       "    'description': 'Empire that began in 1526, known for its architecture and relative peace.',\n",
       "    'type': 'Empire'},\n",
       "   {'id': 'Indian Republic',\n",
       "    'description': 'India has been a federal republic since 1950.',\n",
       "    'type': 'Government'}],\n",
       "  'rels': [{'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'IS_PART_OF',\n",
       "    'end': 'Indomalayan Realm'},\n",
       "   {'start': 'India',\n",
       "    'description': 'About 1,900 public sector companies with complete control and ownership of railways, highways, and majority control in various industries.',\n",
       "    'type': 'HAS',\n",
       "    'end': 'Public_Sector'},\n",
       "   {'start': 'India',\n",
       "    'description': \"One of the world's highest number of billionaires.\",\n",
       "    'type': 'HAS',\n",
       "    'end': 'Billionaires'},\n",
       "   {'start': 'India',\n",
       "    'description': \"World's second-largest labour force with 586 million workers.\",\n",
       "    'type': 'HAS',\n",
       "    'end': 'Labour_Force'},\n",
       "   {'start': 'India',\n",
       "    'description': 'Has free trade agreements with several nations and blocs.',\n",
       "    'type': 'HAS',\n",
       "    'end': 'Free_Trade_Agreements'},\n",
       "   {'start': 'India',\n",
       "    'description': \"Bombay Stock Exchange and National Stock Exchange are among the world's largest stock exchanges.\",\n",
       "    'type': 'HAS',\n",
       "    'end': 'Stock_Exchanges'},\n",
       "   {'start': 'India',\n",
       "    'description': \"Nearly 65% of India's population is rural.\",\n",
       "    'type': 'HAS',\n",
       "    'end': 'Population'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'RELATES_TO',\n",
       "    'end': 'Rigveda'},\n",
       "   {'start': 'India',\n",
       "    'description': 'Member of the World Trade Organization since 1 January 1995.',\n",
       "    'type': 'MEMBER_OF',\n",
       "    'end': 'Wto'},\n",
       "   {'start': 'India',\n",
       "    'description': 'High unemployment and rising income inequality.',\n",
       "    'type': 'FACES',\n",
       "    'end': 'Unemployment'},\n",
       "   {'start': 'India',\n",
       "    'description': 'Adopted broad economic liberalisation in 1991.',\n",
       "    'type': 'ADOPTED',\n",
       "    'end': 'Economic_Liberalisation'},\n",
       "   {'start': 'India',\n",
       "    'description': 'Often considered a welfare state.',\n",
       "    'type': 'CONSIDERED_AS',\n",
       "    'end': 'Welfare_State'},\n",
       "   {'start': 'India', 'description': None, 'type': 'NEAR', 'end': 'Sri Lanka'},\n",
       "   {'start': 'India', 'description': None, 'type': 'NEAR', 'end': 'Maldives'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'BORDERS',\n",
       "    'end': 'Indian Ocean'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'BORDERS',\n",
       "    'end': 'Myanmar'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'BORDERS',\n",
       "    'end': 'Himalayan Mountain Range'},\n",
       "   {'start': 'India', 'description': None, 'type': 'BORDERS', 'end': 'China'},\n",
       "   {'start': 'India', 'description': None, 'type': 'BORDERS', 'end': 'Bhutan'},\n",
       "   {'start': 'India', 'description': None, 'type': 'BORDERS', 'end': 'Nepal'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'BORDERS',\n",
       "    'end': 'Pakistan'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'BORDERS',\n",
       "    'end': 'Bangladesh'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'BORDERS',\n",
       "    'end': 'Arabian Sea'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'BORDERS',\n",
       "    'end': 'Bay Of Bengal'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'SEPARATED_BY',\n",
       "    'end': 'Sri Lanka'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'DERIVED_FROM',\n",
       "    'end': 'Sindhu'},\n",
       "   {'start': 'India',\n",
       "    'description': \"Estimates India's forest cover.\",\n",
       "    'type': 'ESTIMATES',\n",
       "    'end': 'Food And Agriculture Organization Of The United Nations'},\n",
       "   {'start': 'India',\n",
       "    'description': 'Makes up more than 50% of GDP.',\n",
       "    'type': 'MAKES_UP',\n",
       "    'end': 'Service_Sector'},\n",
       "   {'start': 'India',\n",
       "    'description': 'Fifth-largest economy by nominal GDP and third-largest by purchasing power parity (PPP).',\n",
       "    'type': 'RANKS_AS',\n",
       "    'end': 'World'},\n",
       "   {'start': 'India',\n",
       "    'description': 'Fourth-largest consumer market in the world.',\n",
       "    'type': 'RANKS_AS',\n",
       "    'end': 'Consumer_Market'},\n",
       "   {'start': 'India',\n",
       "    'description': \"World's sixth-largest manufacturer, representing 2.6% of global manufacturing output.\",\n",
       "    'type': 'RANKS_AS',\n",
       "    'end': 'Manufacturing'},\n",
       "   {'start': 'India',\n",
       "    'description': 'Officially declared a socialist state as per the constitution.',\n",
       "    'type': 'DECLARED_AS',\n",
       "    'end': 'Socialist_State'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'ORIGIN_OF',\n",
       "    'end': 'Hinduism'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'ORIGIN_OF',\n",
       "    'end': 'Buddhism'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'ORIGIN_OF',\n",
       "    'end': 'Jainism'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'GOVERNED_AS',\n",
       "    'end': 'Indian Republic'},\n",
       "   {'start': 'India',\n",
       "    'description': '136th by GDP (nominal) and 125th by GDP (PPP) on a per capita income basis.',\n",
       "    'type': 'RANKS',\n",
       "    'end': 'Gdp'},\n",
       "   {'start': 'India',\n",
       "    'description': '63rd on the Ease of Doing Business index.',\n",
       "    'type': 'RANKS',\n",
       "    'end': 'Ease_Of_Business_Index'},\n",
       "   {'start': 'India',\n",
       "    'description': '40th on the Global Competitiveness Index.',\n",
       "    'type': 'RANKS',\n",
       "    'end': 'Global_Competitiveness_Index'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'SHARES_BORDERS_WITH',\n",
       "    'end': 'Myanmar'},\n",
       "   {'start': 'India',\n",
       "    'description': 'Overall social welfare spending stood at 8.6% of GDP in 2021-22.',\n",
       "    'type': 'SPENDING',\n",
       "    'end': 'Social_Welfare_Spending'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'HISTORICAL_EVENT',\n",
       "    'end': 'Mughal Empire'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'ORIGINATES_IN',\n",
       "    'end': 'Ganges'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'HAS_BIODIVERSITY_HOTSPOT',\n",
       "    'end': 'Western Ghats'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'HAS_BIODIVERSITY_HOTSPOT',\n",
       "    'end': 'Eastern Himalayas'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'HAS_BIODIVERSITY_HOTSPOT',\n",
       "    'end': 'Indo-Burma Hotspot'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'HAS_ECOSYSTEM',\n",
       "    'end': 'Forests'},\n",
       "   {'start': 'India',\n",
       "    'description': '6% to 7% since the start of the 21st century.',\n",
       "    'type': 'AVERAGE_ANNUAL_GROWTH',\n",
       "    'end': 'Gdp_Growth'},\n",
       "   {'start': 'India',\n",
       "    'description': 'Foreign direct investment in 2021-22 was $82 billion.',\n",
       "    'type': 'FOREIGN_DIRECT_INVESTMENT',\n",
       "    'end': 'Fdi'},\n",
       "   {'start': 'India',\n",
       "    'description': 'Gross domestic savings rate stood at 29.3% of GDP in 2022.',\n",
       "    'type': 'GROSS_DOMESTIC_SAVINGS_RATE',\n",
       "    'end': 'Savings_Rate'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'HUMAN_ORIGIN',\n",
       "    'end': 'Africa'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'HISTORICAL_DEVELOPMENT',\n",
       "    'end': 'Indus Valley Civilisation'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'LANGUAGE_DIFFUSION',\n",
       "    'end': 'Sanskrit'},\n",
       "   {'start': 'Kautalyas Arthashastra',\n",
       "    'description': 'Discusses the need for forest administration.',\n",
       "    'type': 'DISCUSSES',\n",
       "    'end': 'India'},\n",
       "   {'start': 'Indian Forest Act Of 1865',\n",
       "    'description': \"Establishes government's claims over forests.\",\n",
       "    'type': 'ESTABLISHES',\n",
       "    'end': 'India'},\n",
       "   {'start': 'Crown Land (Encroachment) Ordinance',\n",
       "    'description': \"Targets forests in Britain's Asian colonies.\",\n",
       "    'type': 'TARGETS',\n",
       "    'end': 'India'},\n",
       "   {'start': 'Yajnavalkya Smriti',\n",
       "    'description': 'Prohibits the cutting of trees.',\n",
       "    'type': 'PROHIBITS',\n",
       "    'end': 'India'},\n",
       "   {'start': '2013 Forest Survey Of India',\n",
       "    'description': 'Reports on forest cover increase.',\n",
       "    'type': 'REPORTS_ON',\n",
       "    'end': 'India'},\n",
       "   {'start': 'Supreme Court Of India',\n",
       "    'description': None,\n",
       "    'type': 'PART_OF_JUDICIARY',\n",
       "    'end': 'India'},\n",
       "   {'start': 'Indian National Congress',\n",
       "    'description': None,\n",
       "    'type': 'HISTORICALLY_DOMINANT_PARTY',\n",
       "    'end': 'India'},\n",
       "   {'start': 'Forest Act Of 1878',\n",
       "    'description': 'Gives control over all wastelands, including forests.',\n",
       "    'type': 'GIVES_CONTROL',\n",
       "    'end': 'India'},\n",
       "   {'start': 'Sir Dietrich Brandis',\n",
       "    'description': 'Inspector General of Forests in India from 1864 to 1883.',\n",
       "    'type': 'INSPECTOR_GENERAL_OF',\n",
       "    'end': 'India'}]},\n",
       " {'communityId': '0-34',\n",
       "  'nodes': [{'id': 'Constitution Of India',\n",
       "    'description': 'The supreme law of India, laying down the framework for government institutions and fundamental rights.',\n",
       "    'type': 'Document'},\n",
       "   {'id': 'Parliament',\n",
       "    'description': 'Cannot override the Constitution of India.',\n",
       "    'type': 'Institution'},\n",
       "   {'id': 'Government Of India Act 1935',\n",
       "    'description': 'Replaced by the Constitution of India.',\n",
       "    'type': 'Document'},\n",
       "   {'id': 'Constituent Assembly',\n",
       "    'description': 'Tasked with drafting the Constitution of India.',\n",
       "    'type': 'Government body'},\n",
       "   {'id': 'M. N. Roy',\n",
       "    'description': 'Proposed the framework for the Constitution of India.',\n",
       "    'type': 'Person'},\n",
       "   {'id': 'Republic Day',\n",
       "    'description': 'Celebrated on 26 January in India to honor the Constitution.',\n",
       "    'type': 'Event'},\n",
       "   {'id': 'Old Parliament House',\n",
       "    'description': 'Preserves the original 1950 Constitution in a nitrogen-filled case.',\n",
       "    'type': 'Location'},\n",
       "   {'id': 'British Government',\n",
       "    'description': 'Responsible for the external security of India during its dominion status.',\n",
       "    'type': 'Institution'},\n",
       "   {'id': 'Indian Independence Act 1947',\n",
       "    'description': 'Repealed by the Constitution of India.',\n",
       "    'type': 'Document'},\n",
       "   {'id': 'Articles Of The Constitution',\n",
       "    'description': 'Articles 5, 6, 7, 8, 9, 60, 324, 366, 367, 379, 380, 388, 391, 392, 393, and 394 came into force on 26 November 1949.',\n",
       "    'type': 'Document'}],\n",
       "  'rels': [{'start': 'Constitution Of India',\n",
       "    'description': 'The Constitution is based on the proposal suggested by M. N. Roy.',\n",
       "    'type': 'BASED_ON',\n",
       "    'end': 'M. N. Roy'},\n",
       "   {'start': 'Constitution Of India',\n",
       "    'description': 'The original 1950 Constitution is preserved in a nitrogen-filled case.',\n",
       "    'type': 'PRESERVED_IN',\n",
       "    'end': 'Old Parliament House'},\n",
       "   {'start': 'Constitution Of India',\n",
       "    'description': 'Celebrated on 26 January.',\n",
       "    'type': 'CELEBRATED_ON',\n",
       "    'end': 'Republic Day'},\n",
       "   {'start': 'Constitution Of India',\n",
       "    'description': 'Parliament cannot override the Constitution.',\n",
       "    'type': 'CANNOT_OVERRIDE',\n",
       "    'end': 'Parliament'},\n",
       "   {'start': 'Constitution Of India',\n",
       "    'description': 'Certain articles came into force on 26 November 1949.',\n",
       "    'type': 'CAME_INTO_FORCE',\n",
       "    'end': 'Articles Of The Constitution'},\n",
       "   {'start': 'Government Of India Act 1935',\n",
       "    'description': 'Replaced by the Constitution of India.',\n",
       "    'type': 'REPLACED_BY',\n",
       "    'end': 'Constitution Of India'},\n",
       "   {'start': 'British Government',\n",
       "    'description': 'Responsible for the external security of India during its dominion status.',\n",
       "    'type': 'RESPONSIBLE_FOR',\n",
       "    'end': 'Constitution Of India'},\n",
       "   {'start': 'Indian Independence Act 1947',\n",
       "    'description': 'Repealed by the Constitution of India.',\n",
       "    'type': 'REPEALED_BY',\n",
       "    'end': 'Constitution Of India'},\n",
       "   {'start': 'Constituent Assembly',\n",
       "    'description': None,\n",
       "    'type': 'DRAFTED_BY',\n",
       "    'end': 'Constitution Of India'}]},\n",
       " {'communityId': '0-25',\n",
       "  'nodes': [{'id': 'President Of India',\n",
       "    'description': 'The Supreme Commander of the Indian Armed Forces.',\n",
       "    'type': 'Person'},\n",
       "   {'id': 'Nda',\n",
       "    'description': 'A coalition of the BJP and its allies governing India since 2014.',\n",
       "    'type': 'Political alliance'},\n",
       "   {'id': 'Government Of India',\n",
       "    'description': 'Established a system of national parks and protected areas.',\n",
       "    'type': 'Government'},\n",
       "   {'id': 'Narendra Modi',\n",
       "    'description': 'Current Prime Minister of India since 26 May 2014.',\n",
       "    'type': 'Person'},\n",
       "   {'id': 'New Delhi',\n",
       "    'description': 'The seat of the Government of India.',\n",
       "    'type': 'Location'},\n",
       "   {'id': 'Supreme Court',\n",
       "    'description': 'The highest judicial forum and final court of appeal under the Constitution of India.',\n",
       "    'type': 'Judiciary'},\n",
       "   {'id': 'Indian Councils Act 1909',\n",
       "    'description': 'Introduced elections to the Imperial Legislative Council.',\n",
       "    'type': 'Legislation'},\n",
       "   {'id': 'Government Of India Act 1919',\n",
       "    'description': 'Expanded the Imperial Legislative Council.',\n",
       "    'type': 'Legislation'},\n",
       "   {'id': 'National Parks',\n",
       "    'description': 'Established in 1935 and expanded to nearly 1022 by 2023.',\n",
       "    'type': 'Protected area'},\n",
       "   {'id': 'Wildlife Protection Act Of 1972',\n",
       "    'description': 'Enacted for the protection of wildlife.',\n",
       "    'type': 'Legislation'},\n",
       "   {'id': 'Project Tiger',\n",
       "    'description': 'Special project for the protection of critical species.',\n",
       "    'type': 'Conservation project'},\n",
       "   {'id': 'Project Elephant',\n",
       "    'description': 'Special project for the protection of critical species.',\n",
       "    'type': 'Conservation project'},\n",
       "   {'id': 'Project Dolphin',\n",
       "    'description': 'Special project for the protection of critical species.',\n",
       "    'type': 'Conservation project'}],\n",
       "  'rels': [{'start': 'Government Of India',\n",
       "    'description': None,\n",
       "    'type': 'INITIATED',\n",
       "    'end': 'Project Tiger'},\n",
       "   {'start': 'Government Of India',\n",
       "    'description': None,\n",
       "    'type': 'INITIATED',\n",
       "    'end': 'Project Elephant'},\n",
       "   {'start': 'Government Of India',\n",
       "    'description': None,\n",
       "    'type': 'INITIATED',\n",
       "    'end': 'Project Dolphin'},\n",
       "   {'start': 'Government Of India',\n",
       "    'description': None,\n",
       "    'type': 'GOVERNED_BY',\n",
       "    'end': 'Nda'},\n",
       "   {'start': 'Government Of India',\n",
       "    'description': None,\n",
       "    'type': 'ENACTED',\n",
       "    'end': 'Wildlife Protection Act Of 1972'},\n",
       "   {'start': 'Government Of India',\n",
       "    'description': None,\n",
       "    'type': 'ESTABLISHED',\n",
       "    'end': 'National Parks'},\n",
       "   {'start': 'Government Of India',\n",
       "    'description': None,\n",
       "    'type': 'LEAD_BY',\n",
       "    'end': 'Narendra Modi'},\n",
       "   {'start': 'Government Of India',\n",
       "    'description': None,\n",
       "    'type': 'RESPONSIBLE_TO',\n",
       "    'end': 'Supreme Court'},\n",
       "   {'start': 'Government Of India',\n",
       "    'description': None,\n",
       "    'type': 'SEATED_IN',\n",
       "    'end': 'New Delhi'},\n",
       "   {'start': 'Government Of India',\n",
       "    'description': None,\n",
       "    'type': 'HEAD_OF_STATE',\n",
       "    'end': 'President Of India'},\n",
       "   {'start': 'Indian Councils Act 1909',\n",
       "    'description': None,\n",
       "    'type': 'INFLUENCED',\n",
       "    'end': 'Government Of India'},\n",
       "   {'start': 'Government Of India Act 1919',\n",
       "    'description': None,\n",
       "    'type': 'INFLUENCED',\n",
       "    'end': 'Government Of India'}]},\n",
       " {'communityId': '0-112',\n",
       "  'nodes': [{'id': 'Prime Minister Of India',\n",
       "    'description': 'Holds executive authority and responsibility for national security.',\n",
       "    'type': 'Person'},\n",
       "   {'id': 'Indian Armed Forces',\n",
       "    'description': 'The military forces of the Republic of India.',\n",
       "    'type': 'Organization'},\n",
       "   {'id': 'Indian Army',\n",
       "    'description': 'One of the three professional uniformed services of the Indian Armed Forces.',\n",
       "    'type': 'Organization'},\n",
       "   {'id': 'Indian Navy',\n",
       "    'description': 'One of the three professional uniformed services of the Indian Armed Forces.',\n",
       "    'type': 'Organization'},\n",
       "   {'id': 'Indian Air Force',\n",
       "    'description': 'One of the three professional uniformed services of the Indian Armed Forces.',\n",
       "    'type': 'Organization'},\n",
       "   {'id': 'Central Armed Police Forces',\n",
       "    'description': 'Supports the Indian Armed Forces.',\n",
       "    'type': 'Organization'},\n",
       "   {'id': 'Indian Coast Guard',\n",
       "    'description': 'Supports the Indian Armed Forces.',\n",
       "    'type': 'Organization'},\n",
       "   {'id': 'Special Frontier Force',\n",
       "    'description': 'Supports the Indian Armed Forces.',\n",
       "    'type': 'Organization'},\n",
       "   {'id': 'Strategic Forces Command',\n",
       "    'description': 'An inter-service command of the Indian Armed Forces.',\n",
       "    'type': 'Organization'},\n",
       "   {'id': 'Andaman And Nicobar Command',\n",
       "    'description': 'An inter-service command of the Indian Armed Forces.',\n",
       "    'type': 'Organization'},\n",
       "   {'id': 'Integrated Defence Staff',\n",
       "    'description': 'An inter-service command of the Indian Armed Forces.',\n",
       "    'type': 'Organization'},\n",
       "   {'id': 'Ministry Of Defence',\n",
       "    'description': 'Manages the Indian Armed Forces.',\n",
       "    'type': 'Organization'},\n",
       "   {'id': 'Global Firepower Index',\n",
       "    'description': 'Ranks the military forces globally.',\n",
       "    'type': 'Report'},\n",
       "   {'id': 'Armed Forces Flag Day',\n",
       "    'description': 'Honors armed forces and military personnel annually.',\n",
       "    'type': 'Event'},\n",
       "   {'id': 'Mauryan Empire',\n",
       "    'description': 'An ancient Indian empire known for its powerful military.',\n",
       "    'type': 'Empire'},\n",
       "   {'id': 'Chola Empire',\n",
       "    'description': 'Known for foreign trade and maritime activity.',\n",
       "    'type': 'Empire'}],\n",
       "  'rels': [{'start': 'Prime Minister Of India',\n",
       "    'description': None,\n",
       "    'type': 'EXECUTIVE_AUTHORITY',\n",
       "    'end': 'Indian Armed Forces'},\n",
       "   {'start': 'Indian Armed Forces',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Indian Army'},\n",
       "   {'start': 'Indian Armed Forces',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Indian Navy'},\n",
       "   {'start': 'Indian Armed Forces',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Indian Air Force'},\n",
       "   {'start': 'Indian Armed Forces',\n",
       "    'description': None,\n",
       "    'type': 'SUPPORTED_BY',\n",
       "    'end': 'Central Armed Police Forces'},\n",
       "   {'start': 'Indian Armed Forces',\n",
       "    'description': None,\n",
       "    'type': 'SUPPORTED_BY',\n",
       "    'end': 'Indian Coast Guard'},\n",
       "   {'start': 'Indian Armed Forces',\n",
       "    'description': None,\n",
       "    'type': 'SUPPORTED_BY',\n",
       "    'end': 'Special Frontier Force'},\n",
       "   {'start': 'Indian Armed Forces',\n",
       "    'description': None,\n",
       "    'type': 'SUPPORTED_BY',\n",
       "    'end': 'Strategic Forces Command'},\n",
       "   {'start': 'Indian Armed Forces',\n",
       "    'description': None,\n",
       "    'type': 'SUPPORTED_BY',\n",
       "    'end': 'Andaman And Nicobar Command'},\n",
       "   {'start': 'Indian Armed Forces',\n",
       "    'description': None,\n",
       "    'type': 'SUPPORTED_BY',\n",
       "    'end': 'Integrated Defence Staff'},\n",
       "   {'start': 'Ministry Of Defence',\n",
       "    'description': None,\n",
       "    'type': 'MANAGES',\n",
       "    'end': 'Indian Armed Forces'},\n",
       "   {'start': 'Global Firepower Index',\n",
       "    'description': None,\n",
       "    'type': 'RANKS',\n",
       "    'end': 'Indian Armed Forces'},\n",
       "   {'start': 'Armed Forces Flag Day',\n",
       "    'description': None,\n",
       "    'type': 'HONORS',\n",
       "    'end': 'Indian Armed Forces'},\n",
       "   {'start': 'Mauryan Empire',\n",
       "    'description': None,\n",
       "    'type': 'HISTORICAL_REFERENCE',\n",
       "    'end': 'Indian Armed Forces'},\n",
       "   {'start': 'Chola Empire',\n",
       "    'description': None,\n",
       "    'type': 'HISTORICAL_REFERENCE',\n",
       "    'end': 'Indian Armed Forces'}]},\n",
       " {'communityId': '0-27',\n",
       "  'nodes': [{'id': 'Rajya Sabha',\n",
       "    'description': 'The mostly indirectly elected upper house of Parliament.',\n",
       "    'type': 'Government body'},\n",
       "   {'id': 'Lok Sabha',\n",
       "    'description': 'The directly elected lower house of Parliament.',\n",
       "    'type': 'Government body'},\n",
       "   {'id': 'Union Council Of Ministers',\n",
       "    'description': 'The executive decision-making committee of the government.',\n",
       "    'type': 'Government body'}],\n",
       "  'rels': [{'start': 'Union Council Of Ministers',\n",
       "    'description': None,\n",
       "    'type': 'RESPONSIBLE_TO',\n",
       "    'end': 'Rajya Sabha'},\n",
       "   {'start': 'Union Council Of Ministers',\n",
       "    'description': None,\n",
       "    'type': 'RESPONSIBLE_TO',\n",
       "    'end': 'Lok Sabha'}]},\n",
       " {'communityId': '0-11',\n",
       "  'nodes': [{'id': 'Republic Of India',\n",
       "    'description': 'Has two principal official short names, India and Bharat.',\n",
       "    'type': 'Country'},\n",
       "   {'id': 'Hindustan',\n",
       "    'description': 'Commonly used name for the Republic of India.',\n",
       "    'type': 'Name'}],\n",
       "  'rels': [{'start': 'Republic Of India',\n",
       "    'description': None,\n",
       "    'type': 'HAS_NAME',\n",
       "    'end': 'Hindustan'}]},\n",
       " {'communityId': '0-15',\n",
       "  'nodes': [{'id': 'Bharat',\n",
       "    'description': 'Another principal official short name of the Republic of India.',\n",
       "    'type': 'Name'},\n",
       "   {'id': 'Dushyanta',\n",
       "    'description': 'Father of Bharata, associated with the name Bhāratavarṣa.',\n",
       "    'type': 'Person'},\n",
       "   {'id': 'Mahabharata',\n",
       "    'description': 'Epic associated with the name Bharata.',\n",
       "    'type': 'Literature'}],\n",
       "  'rels': [{'start': 'Bharat',\n",
       "    'description': None,\n",
       "    'type': 'ASSOCIATED_WITH',\n",
       "    'end': 'Dushyanta'},\n",
       "   {'start': 'Bharat',\n",
       "    'description': None,\n",
       "    'type': 'ASSOCIATED_WITH',\n",
       "    'end': 'Mahabharata'}]},\n",
       " {'communityId': '0-14',\n",
       "  'nodes': [{'id': 'Bhāratavarṣa',\n",
       "    'description': 'Term used in the first century AD, derived from the name of the Vedic community of Bharatas.',\n",
       "    'type': 'Historical term'},\n",
       "   {'id': 'Bharatas',\n",
       "    'description': 'Mentioned in the Rigveda as one of the principal kingdoms of the Aryavarta.',\n",
       "    'type': 'Vedic community'}],\n",
       "  'rels': [{'start': 'Bhāratavarṣa',\n",
       "    'description': None,\n",
       "    'type': 'DERIVED_FROM',\n",
       "    'end': 'Bharatas'}]},\n",
       " {'communityId': '0-39',\n",
       "  'nodes': [{'id': 'Thailand',\n",
       "    'description': \"Shares maritime borders with India's Andaman and Nicobar Islands.\",\n",
       "    'type': 'Country'},\n",
       "   {'id': 'Indonesia',\n",
       "    'description': \"Shares maritime borders with India's Andaman and Nicobar Islands.\",\n",
       "    'type': 'Country'},\n",
       "   {'id': 'Andaman And Nicobar Islands',\n",
       "    'description': 'Islands of India sharing a maritime border with Thailand, Myanmar, and Indonesia.',\n",
       "    'type': 'Island'}],\n",
       "  'rels': [{'start': 'Andaman And Nicobar Islands',\n",
       "    'description': None,\n",
       "    'type': 'MARITIME_BORDER',\n",
       "    'end': 'Thailand'},\n",
       "   {'start': 'Andaman And Nicobar Islands',\n",
       "    'description': None,\n",
       "    'type': 'MARITIME_BORDER',\n",
       "    'end': 'Indonesia'}]},\n",
       " {'communityId': '0-52',\n",
       "  'nodes': [{'id': 'Constituent Assembly Of India',\n",
       "    'description': 'Adopted the Constitution of India on 26 November 1949.',\n",
       "    'type': 'Institution'},\n",
       "   {'id': 'Sardar Patel',\n",
       "    'description': 'Convinced princely states to sign articles of integration with India.',\n",
       "    'type': 'Person'},\n",
       "   {'id': 'V. P. Menon',\n",
       "    'description': 'Convinced princely states to sign articles of integration with India.',\n",
       "    'type': 'Person'}],\n",
       "  'rels': [{'start': 'Sardar Patel',\n",
       "    'description': 'Convinced princely states to sign articles of integration.',\n",
       "    'type': 'CONVINCED',\n",
       "    'end': 'Constituent Assembly Of India'},\n",
       "   {'start': 'V. P. Menon',\n",
       "    'description': 'Convinced princely states to sign articles of integration.',\n",
       "    'type': 'CONVINCED',\n",
       "    'end': 'Constituent Assembly Of India'}]},\n",
       " {'communityId': '0-78',\n",
       "  'nodes': [{'id': 'Fauna Species',\n",
       "    'description': 'India has an estimated 92,873 species of fauna.',\n",
       "    'type': 'Fauna'},\n",
       "   {'id': 'Insects',\n",
       "    'description': 'Major category with 63,423 recorded species.',\n",
       "    'type': 'Fauna'},\n",
       "   {'id': 'Mammals Count',\n",
       "    'description': '423 mammals in India.',\n",
       "    'type': 'Fauna'},\n",
       "   {'id': 'Birds Count',\n",
       "    'description': '1,233 birds in India.',\n",
       "    'type': 'Fauna'},\n",
       "   {'id': 'Reptiles Count',\n",
       "    'description': '526 reptiles in India.',\n",
       "    'type': 'Fauna'},\n",
       "   {'id': 'Amphibians Count',\n",
       "    'description': '342 amphibians in India.',\n",
       "    'type': 'Fauna'},\n",
       "   {'id': 'Fish Count',\n",
       "    'description': '3,022 fish in India.',\n",
       "    'type': 'Fauna'},\n",
       "   {'id': 'Endemic Mammals',\n",
       "    'description': '12.6% of mammals are endemic to India.',\n",
       "    'type': 'Fauna'},\n",
       "   {'id': 'Endemic Birds',\n",
       "    'description': '4.5% of birds are endemic to India.',\n",
       "    'type': 'Fauna'},\n",
       "   {'id': 'Endemic Reptiles',\n",
       "    'description': '45.8% of reptiles are endemic to India.',\n",
       "    'type': 'Fauna'},\n",
       "   {'id': 'Endemic Amphibians',\n",
       "    'description': '55.8% of amphibians are endemic to India.',\n",
       "    'type': 'Fauna'},\n",
       "   {'id': 'Large Animals',\n",
       "    'description': 'Includes Indian elephant, Indian rhinoceros, and Gaur.',\n",
       "    'type': 'Fauna'},\n",
       "   {'id': 'Big Cats',\n",
       "    'description': 'Includes tiger and lion.',\n",
       "    'type': 'Fauna'},\n",
       "   {'id': 'Cat Family',\n",
       "    'description': 'Includes Bengal tiger, Asiatic lion, Indian leopard, snow leopard, and clouded leopard.',\n",
       "    'type': 'Fauna'},\n",
       "   {'id': 'Representative Species',\n",
       "    'description': 'Includes blackbuck, nilgai, bharal, barasingha, Nilgiri tahr, and Nilgiri langur.',\n",
       "    'type': 'Fauna'},\n",
       "   {'id': 'Aquatic Mammals',\n",
       "    'description': 'Includes dolphins, whales, porpoises, and dugong.',\n",
       "    'type': 'Fauna'},\n",
       "   {'id': 'Reptiles Species',\n",
       "    'description': 'Includes gharial and saltwater crocodiles.',\n",
       "    'type': 'Fauna'},\n",
       "   {'id': 'Birds Species',\n",
       "    'description': 'Includes peafowl, pheasants, geese, ducks, mynas, parakeets, pigeons, cranes, hornbills, and sunbirds.',\n",
       "    'type': 'Fauna'},\n",
       "   {'id': 'Endemic Bird Species',\n",
       "    'description': 'Includes great Indian hornbill, great Indian bustard, nicobar pigeon, ruddy shelduck, Himalayan monal, and Himalayan quail.',\n",
       "    'type': 'Fauna'}],\n",
       "  'rels': [{'start': 'Fauna Species',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Insects'},\n",
       "   {'start': 'Fauna Species',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Mammals Count'},\n",
       "   {'start': 'Fauna Species',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Birds Count'},\n",
       "   {'start': 'Fauna Species',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Reptiles Count'},\n",
       "   {'start': 'Fauna Species',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Amphibians Count'},\n",
       "   {'start': 'Fauna Species',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Fish Count'},\n",
       "   {'start': 'Fauna Species',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Endemic Mammals'},\n",
       "   {'start': 'Fauna Species',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Endemic Birds'},\n",
       "   {'start': 'Fauna Species',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Endemic Reptiles'},\n",
       "   {'start': 'Fauna Species',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Endemic Amphibians'},\n",
       "   {'start': 'Fauna Species',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Large Animals'},\n",
       "   {'start': 'Fauna Species',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Big Cats'},\n",
       "   {'start': 'Fauna Species',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Cat Family'},\n",
       "   {'start': 'Fauna Species',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Representative Species'},\n",
       "   {'start': 'Fauna Species',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Aquatic Mammals'},\n",
       "   {'start': 'Fauna Species',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Reptiles Species'},\n",
       "   {'start': 'Fauna Species',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Birds Species'},\n",
       "   {'start': 'Fauna Species',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Endemic Bird Species'}]},\n",
       " {'communityId': '0-110',\n",
       "  'nodes': [{'id': 'Plant Species',\n",
       "    'description': 'About 29,015 species of plants.',\n",
       "    'type': 'Flora'},\n",
       "   {'id': 'Flowering Plants Count',\n",
       "    'description': '17,926 species of flowering plants.',\n",
       "    'type': 'Flora'},\n",
       "   {'id': 'Endemic Plant Species',\n",
       "    'description': '6,842 species are endemic to India.',\n",
       "    'type': 'Flora'},\n",
       "   {'id': 'Algae', 'description': '7,244 species.', 'type': 'Flora'},\n",
       "   {'id': 'Bryophytes', 'description': '2,504 species.', 'type': 'Flora'},\n",
       "   {'id': 'Pteridophytes', 'description': '1,267 species.', 'type': 'Flora'},\n",
       "   {'id': 'Gymnosperms', 'description': '74 species.', 'type': 'Flora'},\n",
       "   {'id': 'Fungal Diversity',\n",
       "    'description': 'Over 27,000 recorded species.',\n",
       "    'type': 'Flora'},\n",
       "   {'id': 'Flora', 'description': None, 'type': None}],\n",
       "  'rels': [{'start': 'Flora',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Plant Species'},\n",
       "   {'start': 'Flora',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Flowering Plants Count'},\n",
       "   {'start': 'Flora',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Endemic Plant Species'},\n",
       "   {'start': 'Flora', 'description': None, 'type': 'INCLUDES', 'end': 'Algae'},\n",
       "   {'start': 'Flora',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Bryophytes'},\n",
       "   {'start': 'Flora',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Pteridophytes'},\n",
       "   {'start': 'Flora',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Gymnosperms'},\n",
       "   {'start': 'Flora',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Fungal Diversity'}]},\n",
       " {'communityId': '0-105',\n",
       "  'nodes': [{'id': 'Threatened Species',\n",
       "    'description': '172 IUCN-designated threatened species.',\n",
       "    'type': 'Fauna'},\n",
       "   {'id': 'Threatened Mammals',\n",
       "    'description': '39 species of mammals.',\n",
       "    'type': 'Fauna'},\n",
       "   {'id': 'Threatened Birds',\n",
       "    'description': '72 species of birds.',\n",
       "    'type': 'Fauna'},\n",
       "   {'id': 'Threatened Reptiles',\n",
       "    'description': '17 species of reptiles.',\n",
       "    'type': 'Fauna'},\n",
       "   {'id': 'Threatened Amphibians',\n",
       "    'description': '3 species of amphibians.',\n",
       "    'type': 'Fauna'},\n",
       "   {'id': 'Threatened Fish',\n",
       "    'description': '2 species of fish.',\n",
       "    'type': 'Fauna'}],\n",
       "  'rels': [{'start': 'Threatened Species',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Threatened Mammals'},\n",
       "   {'start': 'Threatened Species',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Threatened Birds'},\n",
       "   {'start': 'Threatened Species',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Threatened Reptiles'},\n",
       "   {'start': 'Threatened Species',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Threatened Amphibians'},\n",
       "   {'start': 'Threatened Species',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Threatened Fish'}]},\n",
       " {'communityId': '0-125',\n",
       "  'nodes': [{'id': 'Department Of Defence Production',\n",
       "    'description': 'Responsible for indigenous production of equipment for the Indian Armed Forces.',\n",
       "    'type': 'Organization'},\n",
       "   {'id': 'Make In India Initiative',\n",
       "    'description': 'Seeks to indigenise manufacturing and reduce dependence on imports for defence.',\n",
       "    'type': 'Program'}],\n",
       "  'rels': [{'start': 'Make In India Initiative',\n",
       "    'description': None,\n",
       "    'type': 'SUPPORTS',\n",
       "    'end': 'Department Of Defence Production'}]},\n",
       " {'communityId': '0-169',\n",
       "  'nodes': [{'id': 'Maurya Empire',\n",
       "    'description': 'Ancient empire based in the Ganges Basin.',\n",
       "    'type': 'Empire'},\n",
       "   {'id': 'Gupta Empire',\n",
       "    'description': 'Ancient empire based in the Ganges Basin.',\n",
       "    'type': 'Empire'},\n",
       "   {'id': 'Ganges Basin', 'description': None, 'type': None}],\n",
       "  'rels': [{'start': 'Ganges Basin',\n",
       "    'description': None,\n",
       "    'type': 'BASED_IN',\n",
       "    'end': 'Maurya Empire'},\n",
       "   {'start': 'Ganges Basin',\n",
       "    'description': None,\n",
       "    'type': 'BASED_IN',\n",
       "    'end': 'Gupta Empire'}]},\n",
       " {'communityId': '0-170',\n",
       "  'nodes': [{'id': 'Vijayanagara Empire',\n",
       "    'description': 'Empire in south India that created a composite Hindu culture.',\n",
       "    'type': 'Empire'},\n",
       "   {'id': 'South India', 'description': None, 'type': None}],\n",
       "  'rels': [{'start': 'South India',\n",
       "    'description': None,\n",
       "    'type': 'BASED_IN',\n",
       "    'end': 'Vijayanagara Empire'}]},\n",
       " {'communityId': '0-171',\n",
       "  'nodes': [{'id': 'Sikhism',\n",
       "    'description': 'Religion that emerged in the Punjab, rejecting institutionalised religion.',\n",
       "    'type': 'Religion'},\n",
       "   {'id': 'Punjab', 'description': None, 'type': None}],\n",
       "  'rels': [{'start': 'Punjab',\n",
       "    'description': None,\n",
       "    'type': 'ORIGIN_OF',\n",
       "    'end': 'Sikhism'}]},\n",
       " {'communityId': '0-167',\n",
       "  'nodes': [{'id': 'British East India Company',\n",
       "    'description': 'Company that expanded rule in India, turning it into a colonial economy.',\n",
       "    'type': 'Company'},\n",
       "   {'id': 'British Crown',\n",
       "    'description': 'Began rule in India in 1858.',\n",
       "    'type': 'Government'},\n",
       "   {'id': 'Indian Independence',\n",
       "    'description': 'Event in 1947 when India was partitioned into two independent dominions.',\n",
       "    'type': 'Event'}],\n",
       "  'rels': [{'start': 'British East India Company',\n",
       "    'description': None,\n",
       "    'type': 'HISTORICAL_EVENT',\n",
       "    'end': 'British Crown'},\n",
       "   {'start': 'British Crown',\n",
       "    'description': None,\n",
       "    'type': 'HISTORICAL_EVENT',\n",
       "    'end': 'Indian Independence'}]},\n",
       " {'communityId': '1-23',\n",
       "  'nodes': [{'id': 'India',\n",
       "    'description': 'Officially the Republic of India, located in South Asia.',\n",
       "    'type': 'Country'},\n",
       "   {'id': 'Supreme Court Of India',\n",
       "    'description': 'Head of the independent judiciary.',\n",
       "    'type': 'Judiciary'},\n",
       "   {'id': 'Indian National Congress',\n",
       "    'description': 'Dominated Indian politics until 1977.',\n",
       "    'type': 'Political party'},\n",
       "   {'id': 'Sindhu',\n",
       "    'description': 'Name of the Indus River, from which the name India is derived.',\n",
       "    'type': 'River'},\n",
       "   {'id': 'Food And Agriculture Organization Of The United Nations',\n",
       "    'description': \"Estimates India's forest cover.\",\n",
       "    'type': 'Organization'},\n",
       "   {'id': '2013 Forest Survey Of India',\n",
       "    'description': \"States India's forest cover increased to 69.8 million hectares by 2012.\",\n",
       "    'type': 'Report'},\n",
       "   {'id': 'Yajnavalkya Smriti',\n",
       "    'description': 'Prohibited the cutting of trees.',\n",
       "    'type': 'Literature'},\n",
       "   {'id': 'Kautalyas Arthashastra',\n",
       "    'description': 'Discusses the need for forest administration.',\n",
       "    'type': 'Literature'},\n",
       "   {'id': 'Crown Land (Encroachment) Ordinance',\n",
       "    'description': \"Promulgated in 1840 targeting forests in Britain's Asian colonies.\",\n",
       "    'type': 'Legislation'},\n",
       "   {'id': 'Indian Forest Act Of 1865',\n",
       "    'description': \"Established the government's claims over forests.\",\n",
       "    'type': 'Legislation'},\n",
       "   {'id': 'Forest Act Of 1878',\n",
       "    'description': 'Gave the British government control over all wastelands, including forests.',\n",
       "    'type': 'Legislation'},\n",
       "   {'id': 'Sir Dietrich Brandis',\n",
       "    'description': 'Inspector General of Forests in India from 1864 to 1883.',\n",
       "    'type': 'Person'},\n",
       "   {'id': 'Indian Ocean',\n",
       "    'description': 'Ocean bounded by India on the north.',\n",
       "    'type': 'Ocean'},\n",
       "   {'id': 'Sri Lanka',\n",
       "    'description': 'Country in the vicinity of India in the Indian Ocean.',\n",
       "    'type': 'Country'},\n",
       "   {'id': 'Maldives',\n",
       "    'description': 'Country in the vicinity of India in the Indian Ocean.',\n",
       "    'type': 'Country'},\n",
       "   {'id': 'Myanmar',\n",
       "    'description': 'Country sharing land border with India to the east.',\n",
       "    'type': 'Country'},\n",
       "   {'id': 'Himalayan Mountain Range',\n",
       "    'description': 'Defines the northern frontiers of India.',\n",
       "    'type': 'Mountain range'},\n",
       "   {'id': 'China',\n",
       "    'description': 'Country sharing land border with India to the north.',\n",
       "    'type': 'Country'},\n",
       "   {'id': 'Bhutan',\n",
       "    'description': 'Country sharing land border with India to the north.',\n",
       "    'type': 'Country'},\n",
       "   {'id': 'Nepal',\n",
       "    'description': 'Country sharing land border with India to the north.',\n",
       "    'type': 'Country'},\n",
       "   {'id': 'Pakistan',\n",
       "    'description': 'Country sharing land border with India to the west.',\n",
       "    'type': 'Country'},\n",
       "   {'id': 'Bangladesh',\n",
       "    'description': 'Country sharing land border with India to the east.',\n",
       "    'type': 'Country'},\n",
       "   {'id': 'Ganges',\n",
       "    'description': 'The longest river originating in India.',\n",
       "    'type': 'River'},\n",
       "   {'id': 'Western Ghats',\n",
       "    'description': 'One of the three biodiversity hotspots in India.',\n",
       "    'type': 'Biodiversity hotspot'},\n",
       "   {'id': 'Eastern Himalayas',\n",
       "    'description': 'One of the three biodiversity hotspots in India.',\n",
       "    'type': 'Biodiversity hotspot'},\n",
       "   {'id': 'Indo-Burma Hotspot',\n",
       "    'description': 'One of the three biodiversity hotspots in India.',\n",
       "    'type': 'Biodiversity hotspot'},\n",
       "   {'id': 'Forests',\n",
       "    'description': 'Covers about 24.6% of the total land area.',\n",
       "    'type': 'Ecosystem'},\n",
       "   {'id': 'Indomalayan Realm',\n",
       "    'description': 'Geographical realm that includes India.',\n",
       "    'type': 'Realm'},\n",
       "   {'id': 'World', 'description': None, 'type': None},\n",
       "   {'id': 'Public_Sector', 'description': None, 'type': None},\n",
       "   {'id': 'Gdp', 'description': None, 'type': None},\n",
       "   {'id': 'Economic_Liberalisation', 'description': None, 'type': None},\n",
       "   {'id': 'Gdp_Growth', 'description': None, 'type': None},\n",
       "   {'id': 'Consumer_Market', 'description': None, 'type': None},\n",
       "   {'id': 'Wto', 'description': None, 'type': None},\n",
       "   {'id': 'Ease_Of_Business_Index', 'description': None, 'type': None},\n",
       "   {'id': 'Global_Competitiveness_Index', 'description': None, 'type': None},\n",
       "   {'id': 'Billionaires', 'description': None, 'type': None},\n",
       "   {'id': 'Welfare_State', 'description': None, 'type': None},\n",
       "   {'id': 'Socialist_State', 'description': None, 'type': None},\n",
       "   {'id': 'Social_Welfare_Spending', 'description': None, 'type': None},\n",
       "   {'id': 'Labour_Force', 'description': None, 'type': None},\n",
       "   {'id': 'Fdi', 'description': None, 'type': None},\n",
       "   {'id': 'Free_Trade_Agreements', 'description': None, 'type': None},\n",
       "   {'id': 'Service_Sector', 'description': None, 'type': None},\n",
       "   {'id': 'Stock_Exchanges', 'description': None, 'type': None},\n",
       "   {'id': 'Manufacturing', 'description': None, 'type': None},\n",
       "   {'id': 'Population', 'description': None, 'type': None},\n",
       "   {'id': 'Unemployment', 'description': None, 'type': None},\n",
       "   {'id': 'Savings_Rate', 'description': None, 'type': None},\n",
       "   {'id': 'Arabian Sea',\n",
       "    'description': 'Sea bounded by India on the northwest.',\n",
       "    'type': 'Sea'},\n",
       "   {'id': 'Bay Of Bengal',\n",
       "    'description': 'Bay bounded by India on the southeast.',\n",
       "    'type': 'Bay'},\n",
       "   {'id': 'Africa',\n",
       "    'description': 'Continent from which modern humans arrived on the Indian subcontinent.',\n",
       "    'type': 'Continent'},\n",
       "   {'id': 'Indus Valley Civilisation',\n",
       "    'description': 'Civilisation that evolved from settled life in the western margins of the Indus river basin.',\n",
       "    'type': 'Civilization'},\n",
       "   {'id': 'Sanskrit',\n",
       "    'description': 'Indo-European language that diffused into India from the northwest.',\n",
       "    'type': 'Language'},\n",
       "   {'id': 'Rigveda',\n",
       "    'description': 'Ancient hymns recording the dawning of Hinduism in India.',\n",
       "    'type': 'Text'},\n",
       "   {'id': 'Hinduism',\n",
       "    'description': 'Major religion in India, with roots in the Rigveda.',\n",
       "    'type': 'Religion'},\n",
       "   {'id': 'Buddhism',\n",
       "    'description': 'Religion that arose in India, proclaiming social orders unlinked to heredity.',\n",
       "    'type': 'Religion'},\n",
       "   {'id': 'Jainism',\n",
       "    'description': 'Religion that arose in India, proclaiming social orders unlinked to heredity.',\n",
       "    'type': 'Religion'},\n",
       "   {'id': 'Mughal Empire',\n",
       "    'description': 'Empire that began in 1526, known for its architecture and relative peace.',\n",
       "    'type': 'Empire'},\n",
       "   {'id': 'Indian Republic',\n",
       "    'description': 'India has been a federal republic since 1950.',\n",
       "    'type': 'Government'},\n",
       "   {'id': 'Thailand',\n",
       "    'description': \"Shares maritime borders with India's Andaman and Nicobar Islands.\",\n",
       "    'type': 'Country'},\n",
       "   {'id': 'Indonesia',\n",
       "    'description': \"Shares maritime borders with India's Andaman and Nicobar Islands.\",\n",
       "    'type': 'Country'},\n",
       "   {'id': 'Andaman And Nicobar Islands',\n",
       "    'description': 'Islands of India sharing a maritime border with Thailand, Myanmar, and Indonesia.',\n",
       "    'type': 'Island'}],\n",
       "  'rels': [{'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'IS_PART_OF',\n",
       "    'end': 'Indomalayan Realm'},\n",
       "   {'start': 'India',\n",
       "    'description': 'About 1,900 public sector companies with complete control and ownership of railways, highways, and majority control in various industries.',\n",
       "    'type': 'HAS',\n",
       "    'end': 'Public_Sector'},\n",
       "   {'start': 'India',\n",
       "    'description': \"One of the world's highest number of billionaires.\",\n",
       "    'type': 'HAS',\n",
       "    'end': 'Billionaires'},\n",
       "   {'start': 'India',\n",
       "    'description': \"World's second-largest labour force with 586 million workers.\",\n",
       "    'type': 'HAS',\n",
       "    'end': 'Labour_Force'},\n",
       "   {'start': 'India',\n",
       "    'description': 'Has free trade agreements with several nations and blocs.',\n",
       "    'type': 'HAS',\n",
       "    'end': 'Free_Trade_Agreements'},\n",
       "   {'start': 'India',\n",
       "    'description': \"Bombay Stock Exchange and National Stock Exchange are among the world's largest stock exchanges.\",\n",
       "    'type': 'HAS',\n",
       "    'end': 'Stock_Exchanges'},\n",
       "   {'start': 'India',\n",
       "    'description': \"Nearly 65% of India's population is rural.\",\n",
       "    'type': 'HAS',\n",
       "    'end': 'Population'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'RELATES_TO',\n",
       "    'end': 'Rigveda'},\n",
       "   {'start': 'India',\n",
       "    'description': 'Member of the World Trade Organization since 1 January 1995.',\n",
       "    'type': 'MEMBER_OF',\n",
       "    'end': 'Wto'},\n",
       "   {'start': 'India',\n",
       "    'description': 'High unemployment and rising income inequality.',\n",
       "    'type': 'FACES',\n",
       "    'end': 'Unemployment'},\n",
       "   {'start': 'India',\n",
       "    'description': 'Adopted broad economic liberalisation in 1991.',\n",
       "    'type': 'ADOPTED',\n",
       "    'end': 'Economic_Liberalisation'},\n",
       "   {'start': 'India',\n",
       "    'description': 'Often considered a welfare state.',\n",
       "    'type': 'CONSIDERED_AS',\n",
       "    'end': 'Welfare_State'},\n",
       "   {'start': 'India', 'description': None, 'type': 'NEAR', 'end': 'Sri Lanka'},\n",
       "   {'start': 'India', 'description': None, 'type': 'NEAR', 'end': 'Maldives'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'BORDERS',\n",
       "    'end': 'Indian Ocean'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'BORDERS',\n",
       "    'end': 'Myanmar'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'BORDERS',\n",
       "    'end': 'Himalayan Mountain Range'},\n",
       "   {'start': 'India', 'description': None, 'type': 'BORDERS', 'end': 'China'},\n",
       "   {'start': 'India', 'description': None, 'type': 'BORDERS', 'end': 'Bhutan'},\n",
       "   {'start': 'India', 'description': None, 'type': 'BORDERS', 'end': 'Nepal'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'BORDERS',\n",
       "    'end': 'Pakistan'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'BORDERS',\n",
       "    'end': 'Bangladesh'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'BORDERS',\n",
       "    'end': 'Arabian Sea'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'BORDERS',\n",
       "    'end': 'Bay Of Bengal'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'SEPARATED_BY',\n",
       "    'end': 'Sri Lanka'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'DERIVED_FROM',\n",
       "    'end': 'Sindhu'},\n",
       "   {'start': 'India',\n",
       "    'description': \"Estimates India's forest cover.\",\n",
       "    'type': 'ESTIMATES',\n",
       "    'end': 'Food And Agriculture Organization Of The United Nations'},\n",
       "   {'start': 'India',\n",
       "    'description': 'Makes up more than 50% of GDP.',\n",
       "    'type': 'MAKES_UP',\n",
       "    'end': 'Service_Sector'},\n",
       "   {'start': 'India',\n",
       "    'description': 'Fifth-largest economy by nominal GDP and third-largest by purchasing power parity (PPP).',\n",
       "    'type': 'RANKS_AS',\n",
       "    'end': 'World'},\n",
       "   {'start': 'India',\n",
       "    'description': 'Fourth-largest consumer market in the world.',\n",
       "    'type': 'RANKS_AS',\n",
       "    'end': 'Consumer_Market'},\n",
       "   {'start': 'India',\n",
       "    'description': \"World's sixth-largest manufacturer, representing 2.6% of global manufacturing output.\",\n",
       "    'type': 'RANKS_AS',\n",
       "    'end': 'Manufacturing'},\n",
       "   {'start': 'India',\n",
       "    'description': 'Officially declared a socialist state as per the constitution.',\n",
       "    'type': 'DECLARED_AS',\n",
       "    'end': 'Socialist_State'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'ORIGIN_OF',\n",
       "    'end': 'Hinduism'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'ORIGIN_OF',\n",
       "    'end': 'Buddhism'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'ORIGIN_OF',\n",
       "    'end': 'Jainism'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'GOVERNED_AS',\n",
       "    'end': 'Indian Republic'},\n",
       "   {'start': 'India',\n",
       "    'description': '136th by GDP (nominal) and 125th by GDP (PPP) on a per capita income basis.',\n",
       "    'type': 'RANKS',\n",
       "    'end': 'Gdp'},\n",
       "   {'start': 'India',\n",
       "    'description': '63rd on the Ease of Doing Business index.',\n",
       "    'type': 'RANKS',\n",
       "    'end': 'Ease_Of_Business_Index'},\n",
       "   {'start': 'India',\n",
       "    'description': '40th on the Global Competitiveness Index.',\n",
       "    'type': 'RANKS',\n",
       "    'end': 'Global_Competitiveness_Index'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'SHARES_BORDERS_WITH',\n",
       "    'end': 'Myanmar'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'SHARES_BORDERS_WITH',\n",
       "    'end': 'Thailand'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'SHARES_BORDERS_WITH',\n",
       "    'end': 'Indonesia'},\n",
       "   {'start': 'India',\n",
       "    'description': 'Overall social welfare spending stood at 8.6% of GDP in 2021-22.',\n",
       "    'type': 'SPENDING',\n",
       "    'end': 'Social_Welfare_Spending'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'HISTORICAL_EVENT',\n",
       "    'end': 'Mughal Empire'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'ORIGINATES_IN',\n",
       "    'end': 'Ganges'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'HAS_BIODIVERSITY_HOTSPOT',\n",
       "    'end': 'Western Ghats'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'HAS_BIODIVERSITY_HOTSPOT',\n",
       "    'end': 'Eastern Himalayas'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'HAS_BIODIVERSITY_HOTSPOT',\n",
       "    'end': 'Indo-Burma Hotspot'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'HAS_ECOSYSTEM',\n",
       "    'end': 'Forests'},\n",
       "   {'start': 'India',\n",
       "    'description': '6% to 7% since the start of the 21st century.',\n",
       "    'type': 'AVERAGE_ANNUAL_GROWTH',\n",
       "    'end': 'Gdp_Growth'},\n",
       "   {'start': 'India',\n",
       "    'description': 'Foreign direct investment in 2021-22 was $82 billion.',\n",
       "    'type': 'FOREIGN_DIRECT_INVESTMENT',\n",
       "    'end': 'Fdi'},\n",
       "   {'start': 'India',\n",
       "    'description': 'Gross domestic savings rate stood at 29.3% of GDP in 2022.',\n",
       "    'type': 'GROSS_DOMESTIC_SAVINGS_RATE',\n",
       "    'end': 'Savings_Rate'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'HUMAN_ORIGIN',\n",
       "    'end': 'Africa'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'HISTORICAL_DEVELOPMENT',\n",
       "    'end': 'Indus Valley Civilisation'},\n",
       "   {'start': 'India',\n",
       "    'description': None,\n",
       "    'type': 'LANGUAGE_DIFFUSION',\n",
       "    'end': 'Sanskrit'},\n",
       "   {'start': 'Kautalyas Arthashastra',\n",
       "    'description': 'Discusses the need for forest administration.',\n",
       "    'type': 'DISCUSSES',\n",
       "    'end': 'India'},\n",
       "   {'start': 'Indian Forest Act Of 1865',\n",
       "    'description': \"Establishes government's claims over forests.\",\n",
       "    'type': 'ESTABLISHES',\n",
       "    'end': 'India'},\n",
       "   {'start': 'Crown Land (Encroachment) Ordinance',\n",
       "    'description': \"Targets forests in Britain's Asian colonies.\",\n",
       "    'type': 'TARGETS',\n",
       "    'end': 'India'},\n",
       "   {'start': 'Yajnavalkya Smriti',\n",
       "    'description': 'Prohibits the cutting of trees.',\n",
       "    'type': 'PROHIBITS',\n",
       "    'end': 'India'},\n",
       "   {'start': '2013 Forest Survey Of India',\n",
       "    'description': 'Reports on forest cover increase.',\n",
       "    'type': 'REPORTS_ON',\n",
       "    'end': 'India'},\n",
       "   {'start': 'Supreme Court Of India',\n",
       "    'description': None,\n",
       "    'type': 'PART_OF_JUDICIARY',\n",
       "    'end': 'India'},\n",
       "   {'start': 'Indian National Congress',\n",
       "    'description': None,\n",
       "    'type': 'HISTORICALLY_DOMINANT_PARTY',\n",
       "    'end': 'India'},\n",
       "   {'start': 'Forest Act Of 1878',\n",
       "    'description': 'Gives control over all wastelands, including forests.',\n",
       "    'type': 'GIVES_CONTROL',\n",
       "    'end': 'India'},\n",
       "   {'start': 'Sir Dietrich Brandis',\n",
       "    'description': 'Inspector General of Forests in India from 1864 to 1883.',\n",
       "    'type': 'INSPECTOR_GENERAL_OF',\n",
       "    'end': 'India'},\n",
       "   {'start': 'Andaman And Nicobar Islands',\n",
       "    'description': None,\n",
       "    'type': 'MARITIME_BORDER',\n",
       "    'end': 'Myanmar'},\n",
       "   {'start': 'Andaman And Nicobar Islands',\n",
       "    'description': None,\n",
       "    'type': 'MARITIME_BORDER',\n",
       "    'end': 'Thailand'},\n",
       "   {'start': 'Andaman And Nicobar Islands',\n",
       "    'description': None,\n",
       "    'type': 'MARITIME_BORDER',\n",
       "    'end': 'Indonesia'}]},\n",
       " {'communityId': '1-7',\n",
       "  'nodes': [{'id': 'Constitution Of India',\n",
       "    'description': 'The supreme law of India, laying down the framework for government institutions and fundamental rights.',\n",
       "    'type': 'Document'},\n",
       "   {'id': 'Parliament',\n",
       "    'description': 'Cannot override the Constitution of India.',\n",
       "    'type': 'Institution'},\n",
       "   {'id': 'Government Of India Act 1935',\n",
       "    'description': 'Replaced by the Constitution of India.',\n",
       "    'type': 'Document'},\n",
       "   {'id': 'Constituent Assembly',\n",
       "    'description': 'Tasked with drafting the Constitution of India.',\n",
       "    'type': 'Government body'},\n",
       "   {'id': 'M. N. Roy',\n",
       "    'description': 'Proposed the framework for the Constitution of India.',\n",
       "    'type': 'Person'},\n",
       "   {'id': 'Republic Day',\n",
       "    'description': 'Celebrated on 26 January in India to honor the Constitution.',\n",
       "    'type': 'Event'},\n",
       "   {'id': 'Old Parliament House',\n",
       "    'description': 'Preserves the original 1950 Constitution in a nitrogen-filled case.',\n",
       "    'type': 'Location'},\n",
       "   {'id': 'British Government',\n",
       "    'description': 'Responsible for the external security of India during its dominion status.',\n",
       "    'type': 'Institution'},\n",
       "   {'id': 'Indian Independence Act 1947',\n",
       "    'description': 'Repealed by the Constitution of India.',\n",
       "    'type': 'Document'},\n",
       "   {'id': 'Articles Of The Constitution',\n",
       "    'description': 'Articles 5, 6, 7, 8, 9, 60, 324, 366, 367, 379, 380, 388, 391, 392, 393, and 394 came into force on 26 November 1949.',\n",
       "    'type': 'Document'},\n",
       "   {'id': 'Constituent Assembly Of India',\n",
       "    'description': 'Adopted the Constitution of India on 26 November 1949.',\n",
       "    'type': 'Institution'},\n",
       "   {'id': 'Sardar Patel',\n",
       "    'description': 'Convinced princely states to sign articles of integration with India.',\n",
       "    'type': 'Person'},\n",
       "   {'id': 'V. P. Menon',\n",
       "    'description': 'Convinced princely states to sign articles of integration with India.',\n",
       "    'type': 'Person'}],\n",
       "  'rels': [{'start': 'Constitution Of India',\n",
       "    'description': 'The Constitution is based on the proposal suggested by M. N. Roy.',\n",
       "    'type': 'BASED_ON',\n",
       "    'end': 'M. N. Roy'},\n",
       "   {'start': 'Constitution Of India',\n",
       "    'description': 'Adopted by the Constituent Assembly on 26 November 1949.',\n",
       "    'type': 'ADOPTED_BY',\n",
       "    'end': 'Constituent Assembly Of India'},\n",
       "   {'start': 'Constitution Of India',\n",
       "    'description': 'The original 1950 Constitution is preserved in a nitrogen-filled case.',\n",
       "    'type': 'PRESERVED_IN',\n",
       "    'end': 'Old Parliament House'},\n",
       "   {'start': 'Constitution Of India',\n",
       "    'description': 'Celebrated on 26 January.',\n",
       "    'type': 'CELEBRATED_ON',\n",
       "    'end': 'Republic Day'},\n",
       "   {'start': 'Constitution Of India',\n",
       "    'description': 'Parliament cannot override the Constitution.',\n",
       "    'type': 'CANNOT_OVERRIDE',\n",
       "    'end': 'Parliament'},\n",
       "   {'start': 'Constitution Of India',\n",
       "    'description': 'Certain articles came into force on 26 November 1949.',\n",
       "    'type': 'CAME_INTO_FORCE',\n",
       "    'end': 'Articles Of The Constitution'},\n",
       "   {'start': 'Government Of India Act 1935',\n",
       "    'description': 'Replaced by the Constitution of India.',\n",
       "    'type': 'REPLACED_BY',\n",
       "    'end': 'Constitution Of India'},\n",
       "   {'start': 'British Government',\n",
       "    'description': 'Responsible for the external security of India during its dominion status.',\n",
       "    'type': 'RESPONSIBLE_FOR',\n",
       "    'end': 'Constitution Of India'},\n",
       "   {'start': 'Indian Independence Act 1947',\n",
       "    'description': 'Repealed by the Constitution of India.',\n",
       "    'type': 'REPEALED_BY',\n",
       "    'end': 'Constitution Of India'},\n",
       "   {'start': 'Constituent Assembly',\n",
       "    'description': None,\n",
       "    'type': 'DRAFTED_BY',\n",
       "    'end': 'Constitution Of India'},\n",
       "   {'start': 'Sardar Patel',\n",
       "    'description': 'Convinced princely states to sign articles of integration.',\n",
       "    'type': 'CONVINCED',\n",
       "    'end': 'Constituent Assembly Of India'},\n",
       "   {'start': 'V. P. Menon',\n",
       "    'description': 'Convinced princely states to sign articles of integration.',\n",
       "    'type': 'CONVINCED',\n",
       "    'end': 'Constituent Assembly Of India'}]},\n",
       " {'communityId': '1-4',\n",
       "  'nodes': [{'id': 'President Of India',\n",
       "    'description': 'The Supreme Commander of the Indian Armed Forces.',\n",
       "    'type': 'Person'},\n",
       "   {'id': 'Nda',\n",
       "    'description': 'A coalition of the BJP and its allies governing India since 2014.',\n",
       "    'type': 'Political alliance'},\n",
       "   {'id': 'Government Of India',\n",
       "    'description': 'Established a system of national parks and protected areas.',\n",
       "    'type': 'Government'},\n",
       "   {'id': 'Narendra Modi',\n",
       "    'description': 'Current Prime Minister of India since 26 May 2014.',\n",
       "    'type': 'Person'},\n",
       "   {'id': 'New Delhi',\n",
       "    'description': 'The seat of the Government of India.',\n",
       "    'type': 'Location'},\n",
       "   {'id': 'Supreme Court',\n",
       "    'description': 'The highest judicial forum and final court of appeal under the Constitution of India.',\n",
       "    'type': 'Judiciary'},\n",
       "   {'id': 'Indian Councils Act 1909',\n",
       "    'description': 'Introduced elections to the Imperial Legislative Council.',\n",
       "    'type': 'Legislation'},\n",
       "   {'id': 'Government Of India Act 1919',\n",
       "    'description': 'Expanded the Imperial Legislative Council.',\n",
       "    'type': 'Legislation'},\n",
       "   {'id': 'National Parks',\n",
       "    'description': 'Established in 1935 and expanded to nearly 1022 by 2023.',\n",
       "    'type': 'Protected area'},\n",
       "   {'id': 'Wildlife Protection Act Of 1972',\n",
       "    'description': 'Enacted for the protection of wildlife.',\n",
       "    'type': 'Legislation'},\n",
       "   {'id': 'Project Tiger',\n",
       "    'description': 'Special project for the protection of critical species.',\n",
       "    'type': 'Conservation project'},\n",
       "   {'id': 'Project Elephant',\n",
       "    'description': 'Special project for the protection of critical species.',\n",
       "    'type': 'Conservation project'},\n",
       "   {'id': 'Project Dolphin',\n",
       "    'description': 'Special project for the protection of critical species.',\n",
       "    'type': 'Conservation project'},\n",
       "   {'id': 'Rajya Sabha',\n",
       "    'description': 'The mostly indirectly elected upper house of Parliament.',\n",
       "    'type': 'Government body'},\n",
       "   {'id': 'Lok Sabha',\n",
       "    'description': 'The directly elected lower house of Parliament.',\n",
       "    'type': 'Government body'},\n",
       "   {'id': 'Union Council Of Ministers',\n",
       "    'description': 'The executive decision-making committee of the government.',\n",
       "    'type': 'Government body'}],\n",
       "  'rels': [{'start': 'Government Of India',\n",
       "    'description': None,\n",
       "    'type': 'INITIATED',\n",
       "    'end': 'Project Tiger'},\n",
       "   {'start': 'Government Of India',\n",
       "    'description': None,\n",
       "    'type': 'INITIATED',\n",
       "    'end': 'Project Elephant'},\n",
       "   {'start': 'Government Of India',\n",
       "    'description': None,\n",
       "    'type': 'INITIATED',\n",
       "    'end': 'Project Dolphin'},\n",
       "   {'start': 'Government Of India',\n",
       "    'description': None,\n",
       "    'type': 'GOVERNED_BY',\n",
       "    'end': 'Nda'},\n",
       "   {'start': 'Government Of India',\n",
       "    'description': None,\n",
       "    'type': 'COMPOSED_OF',\n",
       "    'end': 'Union Council Of Ministers'},\n",
       "   {'start': 'Government Of India',\n",
       "    'description': None,\n",
       "    'type': 'ENACTED',\n",
       "    'end': 'Wildlife Protection Act Of 1972'},\n",
       "   {'start': 'Government Of India',\n",
       "    'description': None,\n",
       "    'type': 'ESTABLISHED',\n",
       "    'end': 'National Parks'},\n",
       "   {'start': 'Government Of India',\n",
       "    'description': None,\n",
       "    'type': 'LEAD_BY',\n",
       "    'end': 'Narendra Modi'},\n",
       "   {'start': 'Government Of India',\n",
       "    'description': None,\n",
       "    'type': 'RESPONSIBLE_TO',\n",
       "    'end': 'Supreme Court'},\n",
       "   {'start': 'Government Of India',\n",
       "    'description': None,\n",
       "    'type': 'SEATED_IN',\n",
       "    'end': 'New Delhi'},\n",
       "   {'start': 'Government Of India',\n",
       "    'description': None,\n",
       "    'type': 'HEAD_OF_STATE',\n",
       "    'end': 'President Of India'},\n",
       "   {'start': 'Indian Councils Act 1909',\n",
       "    'description': None,\n",
       "    'type': 'INFLUENCED',\n",
       "    'end': 'Government Of India'},\n",
       "   {'start': 'Government Of India Act 1919',\n",
       "    'description': None,\n",
       "    'type': 'INFLUENCED',\n",
       "    'end': 'Government Of India'},\n",
       "   {'start': 'Union Council Of Ministers',\n",
       "    'description': None,\n",
       "    'type': 'RESPONSIBLE_TO',\n",
       "    'end': 'Rajya Sabha'},\n",
       "   {'start': 'Union Council Of Ministers',\n",
       "    'description': None,\n",
       "    'type': 'RESPONSIBLE_TO',\n",
       "    'end': 'Lok Sabha'}]},\n",
       " {'communityId': '1-22',\n",
       "  'nodes': [{'id': 'Prime Minister Of India',\n",
       "    'description': 'Holds executive authority and responsibility for national security.',\n",
       "    'type': 'Person'},\n",
       "   {'id': 'Indian Armed Forces',\n",
       "    'description': 'The military forces of the Republic of India.',\n",
       "    'type': 'Organization'},\n",
       "   {'id': 'Indian Army',\n",
       "    'description': 'One of the three professional uniformed services of the Indian Armed Forces.',\n",
       "    'type': 'Organization'},\n",
       "   {'id': 'Indian Navy',\n",
       "    'description': 'One of the three professional uniformed services of the Indian Armed Forces.',\n",
       "    'type': 'Organization'},\n",
       "   {'id': 'Indian Air Force',\n",
       "    'description': 'One of the three professional uniformed services of the Indian Armed Forces.',\n",
       "    'type': 'Organization'},\n",
       "   {'id': 'Central Armed Police Forces',\n",
       "    'description': 'Supports the Indian Armed Forces.',\n",
       "    'type': 'Organization'},\n",
       "   {'id': 'Indian Coast Guard',\n",
       "    'description': 'Supports the Indian Armed Forces.',\n",
       "    'type': 'Organization'},\n",
       "   {'id': 'Special Frontier Force',\n",
       "    'description': 'Supports the Indian Armed Forces.',\n",
       "    'type': 'Organization'},\n",
       "   {'id': 'Strategic Forces Command',\n",
       "    'description': 'An inter-service command of the Indian Armed Forces.',\n",
       "    'type': 'Organization'},\n",
       "   {'id': 'Andaman And Nicobar Command',\n",
       "    'description': 'An inter-service command of the Indian Armed Forces.',\n",
       "    'type': 'Organization'},\n",
       "   {'id': 'Integrated Defence Staff',\n",
       "    'description': 'An inter-service command of the Indian Armed Forces.',\n",
       "    'type': 'Organization'},\n",
       "   {'id': 'Ministry Of Defence',\n",
       "    'description': 'Manages the Indian Armed Forces.',\n",
       "    'type': 'Organization'},\n",
       "   {'id': 'Global Firepower Index',\n",
       "    'description': 'Ranks the military forces globally.',\n",
       "    'type': 'Report'},\n",
       "   {'id': 'Armed Forces Flag Day',\n",
       "    'description': 'Honors armed forces and military personnel annually.',\n",
       "    'type': 'Event'},\n",
       "   {'id': 'Mauryan Empire',\n",
       "    'description': 'An ancient Indian empire known for its powerful military.',\n",
       "    'type': 'Empire'},\n",
       "   {'id': 'Chola Empire',\n",
       "    'description': 'Known for foreign trade and maritime activity.',\n",
       "    'type': 'Empire'},\n",
       "   {'id': 'Department Of Defence Production',\n",
       "    'description': 'Responsible for indigenous production of equipment for the Indian Armed Forces.',\n",
       "    'type': 'Organization'},\n",
       "   {'id': 'Make In India Initiative',\n",
       "    'description': 'Seeks to indigenise manufacturing and reduce dependence on imports for defence.',\n",
       "    'type': 'Program'}],\n",
       "  'rels': [{'start': 'Prime Minister Of India',\n",
       "    'description': None,\n",
       "    'type': 'EXECUTIVE_AUTHORITY',\n",
       "    'end': 'Indian Armed Forces'},\n",
       "   {'start': 'Indian Armed Forces',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Indian Army'},\n",
       "   {'start': 'Indian Armed Forces',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Indian Navy'},\n",
       "   {'start': 'Indian Armed Forces',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Indian Air Force'},\n",
       "   {'start': 'Indian Armed Forces',\n",
       "    'description': None,\n",
       "    'type': 'SUPPORTED_BY',\n",
       "    'end': 'Central Armed Police Forces'},\n",
       "   {'start': 'Indian Armed Forces',\n",
       "    'description': None,\n",
       "    'type': 'SUPPORTED_BY',\n",
       "    'end': 'Indian Coast Guard'},\n",
       "   {'start': 'Indian Armed Forces',\n",
       "    'description': None,\n",
       "    'type': 'SUPPORTED_BY',\n",
       "    'end': 'Special Frontier Force'},\n",
       "   {'start': 'Indian Armed Forces',\n",
       "    'description': None,\n",
       "    'type': 'SUPPORTED_BY',\n",
       "    'end': 'Strategic Forces Command'},\n",
       "   {'start': 'Indian Armed Forces',\n",
       "    'description': None,\n",
       "    'type': 'SUPPORTED_BY',\n",
       "    'end': 'Andaman And Nicobar Command'},\n",
       "   {'start': 'Indian Armed Forces',\n",
       "    'description': None,\n",
       "    'type': 'SUPPORTED_BY',\n",
       "    'end': 'Integrated Defence Staff'},\n",
       "   {'start': 'Ministry Of Defence',\n",
       "    'description': None,\n",
       "    'type': 'MANAGES',\n",
       "    'end': 'Indian Armed Forces'},\n",
       "   {'start': 'Global Firepower Index',\n",
       "    'description': None,\n",
       "    'type': 'RANKS',\n",
       "    'end': 'Indian Armed Forces'},\n",
       "   {'start': 'Armed Forces Flag Day',\n",
       "    'description': None,\n",
       "    'type': 'HONORS',\n",
       "    'end': 'Indian Armed Forces'},\n",
       "   {'start': 'Department Of Defence Production',\n",
       "    'description': None,\n",
       "    'type': 'PRODUCES_EQUIPMENT_FOR',\n",
       "    'end': 'Indian Armed Forces'},\n",
       "   {'start': 'Mauryan Empire',\n",
       "    'description': None,\n",
       "    'type': 'HISTORICAL_REFERENCE',\n",
       "    'end': 'Indian Armed Forces'},\n",
       "   {'start': 'Chola Empire',\n",
       "    'description': None,\n",
       "    'type': 'HISTORICAL_REFERENCE',\n",
       "    'end': 'Indian Armed Forces'},\n",
       "   {'start': 'Make In India Initiative',\n",
       "    'description': None,\n",
       "    'type': 'SUPPORTS',\n",
       "    'end': 'Department Of Defence Production'}]},\n",
       " {'communityId': '1-2',\n",
       "  'nodes': [{'id': 'Republic Of India',\n",
       "    'description': 'Has two principal official short names, India and Bharat.',\n",
       "    'type': 'Country'},\n",
       "   {'id': 'Hindustan',\n",
       "    'description': 'Commonly used name for the Republic of India.',\n",
       "    'type': 'Name'},\n",
       "   {'id': 'Bharat',\n",
       "    'description': 'Another principal official short name of the Republic of India.',\n",
       "    'type': 'Name'},\n",
       "   {'id': 'Dushyanta',\n",
       "    'description': 'Father of Bharata, associated with the name Bhāratavarṣa.',\n",
       "    'type': 'Person'},\n",
       "   {'id': 'Mahabharata',\n",
       "    'description': 'Epic associated with the name Bharata.',\n",
       "    'type': 'Literature'},\n",
       "   {'id': 'Bhāratavarṣa',\n",
       "    'description': 'Term used in the first century AD, derived from the name of the Vedic community of Bharatas.',\n",
       "    'type': 'Historical term'},\n",
       "   {'id': 'Bharatas',\n",
       "    'description': 'Mentioned in the Rigveda as one of the principal kingdoms of the Aryavarta.',\n",
       "    'type': 'Vedic community'}],\n",
       "  'rels': [{'start': 'Republic Of India',\n",
       "    'description': None,\n",
       "    'type': 'HAS_NAME',\n",
       "    'end': 'Bharat'},\n",
       "   {'start': 'Republic Of India',\n",
       "    'description': None,\n",
       "    'type': 'HAS_NAME',\n",
       "    'end': 'Hindustan'},\n",
       "   {'start': 'Bharat',\n",
       "    'description': None,\n",
       "    'type': 'ASSOCIATED_WITH',\n",
       "    'end': 'Dushyanta'},\n",
       "   {'start': 'Bharat',\n",
       "    'description': None,\n",
       "    'type': 'ASSOCIATED_WITH',\n",
       "    'end': 'Mahabharata'},\n",
       "   {'start': 'Bharat',\n",
       "    'description': None,\n",
       "    'type': 'DERIVED_FROM',\n",
       "    'end': 'Bhāratavarṣa'},\n",
       "   {'start': 'Bhāratavarṣa',\n",
       "    'description': None,\n",
       "    'type': 'DERIVED_FROM',\n",
       "    'end': 'Bharatas'}]},\n",
       " {'communityId': '1-18',\n",
       "  'nodes': [{'id': 'Fauna Species',\n",
       "    'description': 'India has an estimated 92,873 species of fauna.',\n",
       "    'type': 'Fauna'},\n",
       "   {'id': 'Insects',\n",
       "    'description': 'Major category with 63,423 recorded species.',\n",
       "    'type': 'Fauna'},\n",
       "   {'id': 'Mammals Count',\n",
       "    'description': '423 mammals in India.',\n",
       "    'type': 'Fauna'},\n",
       "   {'id': 'Birds Count',\n",
       "    'description': '1,233 birds in India.',\n",
       "    'type': 'Fauna'},\n",
       "   {'id': 'Reptiles Count',\n",
       "    'description': '526 reptiles in India.',\n",
       "    'type': 'Fauna'},\n",
       "   {'id': 'Amphibians Count',\n",
       "    'description': '342 amphibians in India.',\n",
       "    'type': 'Fauna'},\n",
       "   {'id': 'Fish Count',\n",
       "    'description': '3,022 fish in India.',\n",
       "    'type': 'Fauna'},\n",
       "   {'id': 'Endemic Mammals',\n",
       "    'description': '12.6% of mammals are endemic to India.',\n",
       "    'type': 'Fauna'},\n",
       "   {'id': 'Endemic Birds',\n",
       "    'description': '4.5% of birds are endemic to India.',\n",
       "    'type': 'Fauna'},\n",
       "   {'id': 'Endemic Reptiles',\n",
       "    'description': '45.8% of reptiles are endemic to India.',\n",
       "    'type': 'Fauna'},\n",
       "   {'id': 'Endemic Amphibians',\n",
       "    'description': '55.8% of amphibians are endemic to India.',\n",
       "    'type': 'Fauna'},\n",
       "   {'id': 'Large Animals',\n",
       "    'description': 'Includes Indian elephant, Indian rhinoceros, and Gaur.',\n",
       "    'type': 'Fauna'},\n",
       "   {'id': 'Big Cats',\n",
       "    'description': 'Includes tiger and lion.',\n",
       "    'type': 'Fauna'},\n",
       "   {'id': 'Cat Family',\n",
       "    'description': 'Includes Bengal tiger, Asiatic lion, Indian leopard, snow leopard, and clouded leopard.',\n",
       "    'type': 'Fauna'},\n",
       "   {'id': 'Representative Species',\n",
       "    'description': 'Includes blackbuck, nilgai, bharal, barasingha, Nilgiri tahr, and Nilgiri langur.',\n",
       "    'type': 'Fauna'},\n",
       "   {'id': 'Aquatic Mammals',\n",
       "    'description': 'Includes dolphins, whales, porpoises, and dugong.',\n",
       "    'type': 'Fauna'},\n",
       "   {'id': 'Reptiles Species',\n",
       "    'description': 'Includes gharial and saltwater crocodiles.',\n",
       "    'type': 'Fauna'},\n",
       "   {'id': 'Birds Species',\n",
       "    'description': 'Includes peafowl, pheasants, geese, ducks, mynas, parakeets, pigeons, cranes, hornbills, and sunbirds.',\n",
       "    'type': 'Fauna'},\n",
       "   {'id': 'Endemic Bird Species',\n",
       "    'description': 'Includes great Indian hornbill, great Indian bustard, nicobar pigeon, ruddy shelduck, Himalayan monal, and Himalayan quail.',\n",
       "    'type': 'Fauna'}],\n",
       "  'rels': [{'start': 'Fauna Species',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Insects'},\n",
       "   {'start': 'Fauna Species',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Mammals Count'},\n",
       "   {'start': 'Fauna Species',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Birds Count'},\n",
       "   {'start': 'Fauna Species',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Reptiles Count'},\n",
       "   {'start': 'Fauna Species',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Amphibians Count'},\n",
       "   {'start': 'Fauna Species',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Fish Count'},\n",
       "   {'start': 'Fauna Species',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Endemic Mammals'},\n",
       "   {'start': 'Fauna Species',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Endemic Birds'},\n",
       "   {'start': 'Fauna Species',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Endemic Reptiles'},\n",
       "   {'start': 'Fauna Species',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Endemic Amphibians'},\n",
       "   {'start': 'Fauna Species',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Large Animals'},\n",
       "   {'start': 'Fauna Species',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Big Cats'},\n",
       "   {'start': 'Fauna Species',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Cat Family'},\n",
       "   {'start': 'Fauna Species',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Representative Species'},\n",
       "   {'start': 'Fauna Species',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Aquatic Mammals'},\n",
       "   {'start': 'Fauna Species',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Reptiles Species'},\n",
       "   {'start': 'Fauna Species',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Birds Species'},\n",
       "   {'start': 'Fauna Species',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Endemic Bird Species'}]},\n",
       " {'communityId': '1-20',\n",
       "  'nodes': [{'id': 'Plant Species',\n",
       "    'description': 'About 29,015 species of plants.',\n",
       "    'type': 'Flora'},\n",
       "   {'id': 'Flowering Plants Count',\n",
       "    'description': '17,926 species of flowering plants.',\n",
       "    'type': 'Flora'},\n",
       "   {'id': 'Endemic Plant Species',\n",
       "    'description': '6,842 species are endemic to India.',\n",
       "    'type': 'Flora'},\n",
       "   {'id': 'Algae', 'description': '7,244 species.', 'type': 'Flora'},\n",
       "   {'id': 'Bryophytes', 'description': '2,504 species.', 'type': 'Flora'},\n",
       "   {'id': 'Pteridophytes', 'description': '1,267 species.', 'type': 'Flora'},\n",
       "   {'id': 'Gymnosperms', 'description': '74 species.', 'type': 'Flora'},\n",
       "   {'id': 'Fungal Diversity',\n",
       "    'description': 'Over 27,000 recorded species.',\n",
       "    'type': 'Flora'},\n",
       "   {'id': 'Flora', 'description': None, 'type': None}],\n",
       "  'rels': [{'start': 'Flora',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Plant Species'},\n",
       "   {'start': 'Flora',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Flowering Plants Count'},\n",
       "   {'start': 'Flora',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Endemic Plant Species'},\n",
       "   {'start': 'Flora', 'description': None, 'type': 'INCLUDES', 'end': 'Algae'},\n",
       "   {'start': 'Flora',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Bryophytes'},\n",
       "   {'start': 'Flora',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Pteridophytes'},\n",
       "   {'start': 'Flora',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Gymnosperms'},\n",
       "   {'start': 'Flora',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Fungal Diversity'}]},\n",
       " {'communityId': '1-19',\n",
       "  'nodes': [{'id': 'Threatened Species',\n",
       "    'description': '172 IUCN-designated threatened species.',\n",
       "    'type': 'Fauna'},\n",
       "   {'id': 'Threatened Mammals',\n",
       "    'description': '39 species of mammals.',\n",
       "    'type': 'Fauna'},\n",
       "   {'id': 'Threatened Birds',\n",
       "    'description': '72 species of birds.',\n",
       "    'type': 'Fauna'},\n",
       "   {'id': 'Threatened Reptiles',\n",
       "    'description': '17 species of reptiles.',\n",
       "    'type': 'Fauna'},\n",
       "   {'id': 'Threatened Amphibians',\n",
       "    'description': '3 species of amphibians.',\n",
       "    'type': 'Fauna'},\n",
       "   {'id': 'Threatened Fish',\n",
       "    'description': '2 species of fish.',\n",
       "    'type': 'Fauna'}],\n",
       "  'rels': [{'start': 'Threatened Species',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Threatened Mammals'},\n",
       "   {'start': 'Threatened Species',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Threatened Birds'},\n",
       "   {'start': 'Threatened Species',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Threatened Reptiles'},\n",
       "   {'start': 'Threatened Species',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Threatened Amphibians'},\n",
       "   {'start': 'Threatened Species',\n",
       "    'description': None,\n",
       "    'type': 'INCLUDES',\n",
       "    'end': 'Threatened Fish'}]},\n",
       " {'communityId': '1-25',\n",
       "  'nodes': [{'id': 'Maurya Empire',\n",
       "    'description': 'Ancient empire based in the Ganges Basin.',\n",
       "    'type': 'Empire'},\n",
       "   {'id': 'Gupta Empire',\n",
       "    'description': 'Ancient empire based in the Ganges Basin.',\n",
       "    'type': 'Empire'},\n",
       "   {'id': 'Ganges Basin', 'description': None, 'type': None}],\n",
       "  'rels': [{'start': 'Ganges Basin',\n",
       "    'description': None,\n",
       "    'type': 'BASED_IN',\n",
       "    'end': 'Maurya Empire'},\n",
       "   {'start': 'Ganges Basin',\n",
       "    'description': None,\n",
       "    'type': 'BASED_IN',\n",
       "    'end': 'Gupta Empire'}]},\n",
       " {'communityId': '1-26',\n",
       "  'nodes': [{'id': 'Vijayanagara Empire',\n",
       "    'description': 'Empire in south India that created a composite Hindu culture.',\n",
       "    'type': 'Empire'},\n",
       "   {'id': 'South India', 'description': None, 'type': None}],\n",
       "  'rels': [{'start': 'South India',\n",
       "    'description': None,\n",
       "    'type': 'BASED_IN',\n",
       "    'end': 'Vijayanagara Empire'}]},\n",
       " {'communityId': '1-27',\n",
       "  'nodes': [{'id': 'Sikhism',\n",
       "    'description': 'Religion that emerged in the Punjab, rejecting institutionalised religion.',\n",
       "    'type': 'Religion'},\n",
       "   {'id': 'Punjab', 'description': None, 'type': None}],\n",
       "  'rels': [{'start': 'Punjab',\n",
       "    'description': None,\n",
       "    'type': 'ORIGIN_OF',\n",
       "    'end': 'Sikhism'}]},\n",
       " {'communityId': '1-24',\n",
       "  'nodes': [{'id': 'British East India Company',\n",
       "    'description': 'Company that expanded rule in India, turning it into a colonial economy.',\n",
       "    'type': 'Company'},\n",
       "   {'id': 'British Crown',\n",
       "    'description': 'Began rule in India in 1858.',\n",
       "    'type': 'Government'},\n",
       "   {'id': 'Indian Independence',\n",
       "    'description': 'Event in 1947 when India was partitioned into two independent dominions.',\n",
       "    'type': 'Event'}],\n",
       "  'rels': [{'start': 'British East India Company',\n",
       "    'description': None,\n",
       "    'type': 'HISTORICAL_EVENT',\n",
       "    'end': 'British Crown'},\n",
       "   {'start': 'British Crown',\n",
       "    'description': None,\n",
       "    'type': 'HISTORICAL_EVENT',\n",
       "    'end': 'Indian Independence'}]}]"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "community_info"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "community_template = \"\"\"Based on the provided nodes and relationships that belong to the same graph community,\n",
    "generate a natural language summary of the provided information:\n",
    "{community_info}\n",
    "\n",
    "Summary:\"\"\"  \n",
    "model = \"openai-gpt-4o\"\n",
    "llm, model_name = get_llm(model)\n",
    "community_prompt = ChatPromptTemplate.from_messages(\n",
    "    [\n",
    "        (\n",
    "            \"system\",\n",
    "            \"Given an input triples, generate the information summary. No pre-amble.\",\n",
    "        ),\n",
    "        (\"human\", community_template),\n",
    "    ]\n",
    ")\n",
    "\n",
    "community_chain = community_prompt | llm | StrOutputParser()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "def prepare_string(data):\n",
    "    nodes_str = \"Nodes are:\\n\"\n",
    "    for node in data['nodes']:\n",
    "        node_id = node['id']\n",
    "        node_type = node['type']\n",
    "        if 'description' in node and node['description']:\n",
    "            node_description = f\", description: {node['description']}\"\n",
    "        else:\n",
    "            node_description = \"\"\n",
    "        nodes_str += f\"id: {node_id}, type: {node_type}{node_description}\\n\"\n",
    "\n",
    "    rels_str = \"Relationships are:\\n\"\n",
    "    for rel in data['rels']:\n",
    "        start = rel['start']\n",
    "        end = rel['end']\n",
    "        rel_type = rel['type']\n",
    "        if 'description' in rel and rel['description']:\n",
    "            description = f\", description: {rel['description']}\"\n",
    "        else:\n",
    "            description = \"\"\n",
    "        rels_str += f\"({start})-[:{rel_type}]->({end}){description}\\n\"\n",
    "\n",
    "    return nodes_str + \"\\n\" + rels_str\n",
    "\n",
    "def process_community(community):\n",
    "    stringify_info = prepare_string(community)\n",
    "    summary = community_chain.invoke({'community_info': stringify_info})\n",
    "    return {\"community\": community['communityId'], \"summary\": summary}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Nodes are:\n",
      "id: India, type: Country, description: Officially the Republic of India, located in South Asia.\n",
      "id: Supreme Court Of India, type: Judiciary, description: Head of the independent judiciary.\n",
      "id: Indian National Congress, type: Political party, description: Dominated Indian politics until 1977.\n",
      "id: Sindhu, type: River, description: Name of the Indus River, from which the name India is derived.\n",
      "id: Food And Agriculture Organization Of The United Nations, type: Organization, description: Estimates India's forest cover.\n",
      "id: 2013 Forest Survey Of India, type: Report, description: States India's forest cover increased to 69.8 million hectares by 2012.\n",
      "id: Yajnavalkya Smriti, type: Literature, description: Prohibited the cutting of trees.\n",
      "id: Kautalyas Arthashastra, type: Literature, description: Discusses the need for forest administration.\n",
      "id: Crown Land (Encroachment) Ordinance, type: Legislation, description: Promulgated in 1840 targeting forests in Britain's Asian colonies.\n",
      "id: Indian Forest Act Of 1865, type: Legislation, description: Established the government's claims over forests.\n",
      "id: Forest Act Of 1878, type: Legislation, description: Gave the British government control over all wastelands, including forests.\n",
      "id: Sir Dietrich Brandis, type: Person, description: Inspector General of Forests in India from 1864 to 1883.\n",
      "id: Indian Ocean, type: Ocean, description: Ocean bounded by India on the north.\n",
      "id: Sri Lanka, type: Country, description: Country in the vicinity of India in the Indian Ocean.\n",
      "id: Maldives, type: Country, description: Country in the vicinity of India in the Indian Ocean.\n",
      "id: Myanmar, type: Country, description: Country sharing land border with India to the east.\n",
      "id: Himalayan Mountain Range, type: Mountain range, description: Defines the northern frontiers of India.\n",
      "id: China, type: Country, description: Country sharing land border with India to the north.\n",
      "id: Bhutan, type: Country, description: Country sharing land border with India to the north.\n",
      "id: Nepal, type: Country, description: Country sharing land border with India to the north.\n",
      "id: Pakistan, type: Country, description: Country sharing land border with India to the west.\n",
      "id: Bangladesh, type: Country, description: Country sharing land border with India to the east.\n",
      "id: Ganges, type: River, description: The longest river originating in India.\n",
      "id: Western Ghats, type: Biodiversity hotspot, description: One of the three biodiversity hotspots in India.\n",
      "id: Eastern Himalayas, type: Biodiversity hotspot, description: One of the three biodiversity hotspots in India.\n",
      "id: Indo-Burma Hotspot, type: Biodiversity hotspot, description: One of the three biodiversity hotspots in India.\n",
      "id: Forests, type: Ecosystem, description: Covers about 24.6% of the total land area.\n",
      "id: Indomalayan Realm, type: Realm, description: Geographical realm that includes India.\n",
      "id: World, type: None\n",
      "id: Public_Sector, type: None\n",
      "id: Gdp, type: None\n",
      "id: Economic_Liberalisation, type: None\n",
      "id: Gdp_Growth, type: None\n",
      "id: Consumer_Market, type: None\n",
      "id: Wto, type: None\n",
      "id: Ease_Of_Business_Index, type: None\n",
      "id: Global_Competitiveness_Index, type: None\n",
      "id: Billionaires, type: None\n",
      "id: Welfare_State, type: None\n",
      "id: Socialist_State, type: None\n",
      "id: Social_Welfare_Spending, type: None\n",
      "id: Labour_Force, type: None\n",
      "id: Fdi, type: None\n",
      "id: Free_Trade_Agreements, type: None\n",
      "id: Service_Sector, type: None\n",
      "id: Stock_Exchanges, type: None\n",
      "id: Manufacturing, type: None\n",
      "id: Population, type: None\n",
      "id: Unemployment, type: None\n",
      "id: Savings_Rate, type: None\n",
      "id: Arabian Sea, type: Sea, description: Sea bounded by India on the northwest.\n",
      "id: Bay Of Bengal, type: Bay, description: Bay bounded by India on the southeast.\n",
      "id: Africa, type: Continent, description: Continent from which modern humans arrived on the Indian subcontinent.\n",
      "id: Indus Valley Civilisation, type: Civilization, description: Civilisation that evolved from settled life in the western margins of the Indus river basin.\n",
      "id: Sanskrit, type: Language, description: Indo-European language that diffused into India from the northwest.\n",
      "id: Rigveda, type: Text, description: Ancient hymns recording the dawning of Hinduism in India.\n",
      "id: Hinduism, type: Religion, description: Major religion in India, with roots in the Rigveda.\n",
      "id: Buddhism, type: Religion, description: Religion that arose in India, proclaiming social orders unlinked to heredity.\n",
      "id: Jainism, type: Religion, description: Religion that arose in India, proclaiming social orders unlinked to heredity.\n",
      "id: Mughal Empire, type: Empire, description: Empire that began in 1526, known for its architecture and relative peace.\n",
      "id: Indian Republic, type: Government, description: India has been a federal republic since 1950.\n",
      "\n",
      "Relationships are:\n",
      "(India)-[:IS_PART_OF]->(Indomalayan Realm)\n",
      "(India)-[:HAS]->(Public_Sector), description: About 1,900 public sector companies with complete control and ownership of railways, highways, and majority control in various industries.\n",
      "(India)-[:HAS]->(Billionaires), description: One of the world's highest number of billionaires.\n",
      "(India)-[:HAS]->(Labour_Force), description: World's second-largest labour force with 586 million workers.\n",
      "(India)-[:HAS]->(Free_Trade_Agreements), description: Has free trade agreements with several nations and blocs.\n",
      "(India)-[:HAS]->(Stock_Exchanges), description: Bombay Stock Exchange and National Stock Exchange are among the world's largest stock exchanges.\n",
      "(India)-[:HAS]->(Population), description: Nearly 65% of India's population is rural.\n",
      "(India)-[:RELATES_TO]->(Rigveda)\n",
      "(India)-[:MEMBER_OF]->(Wto), description: Member of the World Trade Organization since 1 January 1995.\n",
      "(India)-[:FACES]->(Unemployment), description: High unemployment and rising income inequality.\n",
      "(India)-[:ADOPTED]->(Economic_Liberalisation), description: Adopted broad economic liberalisation in 1991.\n",
      "(India)-[:CONSIDERED_AS]->(Welfare_State), description: Often considered a welfare state.\n",
      "(India)-[:NEAR]->(Sri Lanka)\n",
      "(India)-[:NEAR]->(Maldives)\n",
      "(India)-[:BORDERS]->(Indian Ocean)\n",
      "(India)-[:BORDERS]->(Myanmar)\n",
      "(India)-[:BORDERS]->(Himalayan Mountain Range)\n",
      "(India)-[:BORDERS]->(China)\n",
      "(India)-[:BORDERS]->(Bhutan)\n",
      "(India)-[:BORDERS]->(Nepal)\n",
      "(India)-[:BORDERS]->(Pakistan)\n",
      "(India)-[:BORDERS]->(Bangladesh)\n",
      "(India)-[:BORDERS]->(Arabian Sea)\n",
      "(India)-[:BORDERS]->(Bay Of Bengal)\n",
      "(India)-[:SEPARATED_BY]->(Sri Lanka)\n",
      "(India)-[:DERIVED_FROM]->(Sindhu)\n",
      "(India)-[:ESTIMATES]->(Food And Agriculture Organization Of The United Nations), description: Estimates India's forest cover.\n",
      "(India)-[:MAKES_UP]->(Service_Sector), description: Makes up more than 50% of GDP.\n",
      "(India)-[:RANKS_AS]->(World), description: Fifth-largest economy by nominal GDP and third-largest by purchasing power parity (PPP).\n",
      "(India)-[:RANKS_AS]->(Consumer_Market), description: Fourth-largest consumer market in the world.\n",
      "(India)-[:RANKS_AS]->(Manufacturing), description: World's sixth-largest manufacturer, representing 2.6% of global manufacturing output.\n",
      "(India)-[:DECLARED_AS]->(Socialist_State), description: Officially declared a socialist state as per the constitution.\n",
      "(India)-[:ORIGIN_OF]->(Hinduism)\n",
      "(India)-[:ORIGIN_OF]->(Buddhism)\n",
      "(India)-[:ORIGIN_OF]->(Jainism)\n",
      "(India)-[:GOVERNED_AS]->(Indian Republic)\n",
      "(India)-[:RANKS]->(Gdp), description: 136th by GDP (nominal) and 125th by GDP (PPP) on a per capita income basis.\n",
      "(India)-[:RANKS]->(Ease_Of_Business_Index), description: 63rd on the Ease of Doing Business index.\n",
      "(India)-[:RANKS]->(Global_Competitiveness_Index), description: 40th on the Global Competitiveness Index.\n",
      "(India)-[:SHARES_BORDERS_WITH]->(Myanmar)\n",
      "(India)-[:SPENDING]->(Social_Welfare_Spending), description: Overall social welfare spending stood at 8.6% of GDP in 2021-22.\n",
      "(India)-[:HISTORICAL_EVENT]->(Mughal Empire)\n",
      "(India)-[:ORIGINATES_IN]->(Ganges)\n",
      "(India)-[:HAS_BIODIVERSITY_HOTSPOT]->(Western Ghats)\n",
      "(India)-[:HAS_BIODIVERSITY_HOTSPOT]->(Eastern Himalayas)\n",
      "(India)-[:HAS_BIODIVERSITY_HOTSPOT]->(Indo-Burma Hotspot)\n",
      "(India)-[:HAS_ECOSYSTEM]->(Forests)\n",
      "(India)-[:AVERAGE_ANNUAL_GROWTH]->(Gdp_Growth), description: 6% to 7% since the start of the 21st century.\n",
      "(India)-[:FOREIGN_DIRECT_INVESTMENT]->(Fdi), description: Foreign direct investment in 2021-22 was $82 billion.\n",
      "(India)-[:GROSS_DOMESTIC_SAVINGS_RATE]->(Savings_Rate), description: Gross domestic savings rate stood at 29.3% of GDP in 2022.\n",
      "(India)-[:HUMAN_ORIGIN]->(Africa)\n",
      "(India)-[:HISTORICAL_DEVELOPMENT]->(Indus Valley Civilisation)\n",
      "(India)-[:LANGUAGE_DIFFUSION]->(Sanskrit)\n",
      "(Kautalyas Arthashastra)-[:DISCUSSES]->(India), description: Discusses the need for forest administration.\n",
      "(Indian Forest Act Of 1865)-[:ESTABLISHES]->(India), description: Establishes government's claims over forests.\n",
      "(Crown Land (Encroachment) Ordinance)-[:TARGETS]->(India), description: Targets forests in Britain's Asian colonies.\n",
      "(Yajnavalkya Smriti)-[:PROHIBITS]->(India), description: Prohibits the cutting of trees.\n",
      "(2013 Forest Survey Of India)-[:REPORTS_ON]->(India), description: Reports on forest cover increase.\n",
      "(Supreme Court Of India)-[:PART_OF_JUDICIARY]->(India)\n",
      "(Indian National Congress)-[:HISTORICALLY_DOMINANT_PARTY]->(India)\n",
      "(Forest Act Of 1878)-[:GIVES_CONTROL]->(India), description: Gives control over all wastelands, including forests.\n",
      "(Sir Dietrich Brandis)-[:INSPECTOR_GENERAL_OF]->(India), description: Inspector General of Forests in India from 1864 to 1883.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "print(prepare_string(community_info[0]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Processing communities:   0%|          | 0/30 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Processing communities: 100%|██████████| 30/30 [00:20<00:00,  1.48it/s]\n"
     ]
    }
   ],
   "source": [
    "\n",
    "\n",
    "MAX_WORKERS = 10\n",
    "summaries = []\n",
    "with ThreadPoolExecutor() as executor:\n",
    "    futures = {executor.submit(process_community, community): community for community in community_info}\n",
    "\n",
    "    for future in tqdm(as_completed(futures), total=len(futures), desc=\"Processing communities\"):\n",
    "        summaries.append(future.result())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[]"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Store summaries\n",
    "graph.query(\"\"\"\n",
    "UNWIND $data AS row\n",
    "MERGE (c:__Community__ {id:row.community})\n",
    "SET c.summary = row.summary\n",
    "\"\"\", params={\"data\": summaries})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def db_query(cypher: str, params: Dict[str, Any] = {}) -> pd.DataFrame:\n",
    "    \"\"\"Executes a Cypher statement and returns a DataFrame\"\"\"\n",
    "    return driver.execute_query(\n",
    "        cypher, parameters_=params, result_transformer_=Result.to_df\n",
    "    )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "## Calculate before \n",
    "db_query(\n",
    "    \"\"\"\n",
    "MATCH (n:`__Community__`)<-[:IN_COMMUNITY]-()<-[:HAS_ENTITY]-(c)\n",
    "WITH n, count(distinct c) AS chunkCount\n",
    "SET n.weight = chunkCount\"\"\"\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## local and global search"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "index_name = \"entity_local\"\n",
    "\n",
    "# db_query(\n",
    "#     \"\"\"\n",
    "# CREATE VECTOR INDEX \"\"\"\n",
    "#     + index_name\n",
    "#     + \"\"\" IF NOT EXISTS FOR (e:__Entity__) ON e.embedding\n",
    "# OPTIONS {indexConfig: {\n",
    "#  `vector.dimensions`: 384,\n",
    "#  `vector.similarity_function`: 'cosine'\n",
    "# }}\n",
    "# \"\"\"\n",
    "# )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "topChunks = 3\n",
    "topCommunities = 3\n",
    "topOutsideRels = 10\n",
    "topInsideRels = 10\n",
    "topEntities = 10"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "lc_retrieval_query = \"\"\"\n",
    "WITH collect(node) as nodes\n",
    "// Entity - Text Unit Mapping\n",
    "WITH\n",
    "collect {\n",
    "    UNWIND nodes as n\n",
    "    MATCH (n)<-[:HAS_ENTITY]->(c:Chunk)\n",
    "    WITH c, count(distinct n) as freq\n",
    "    RETURN c.text AS chunkText\n",
    "    ORDER BY freq DESC\n",
    "    LIMIT $topChunks\n",
    "} AS text_mapping,\n",
    "// Entity - Report Mapping\n",
    "collect {\n",
    "    UNWIND nodes as n\n",
    "    MATCH (n)-[:IN_COMMUNITY]->(c:__Community__)\n",
    "    WITH c, c.rank as rank, c.weight AS weight\n",
    "    RETURN c.summary \n",
    "    ORDER BY rank, weight DESC\n",
    "    LIMIT $topCommunities\n",
    "} AS report_mapping,\n",
    "// Outside Relationships \n",
    "collect {\n",
    "    UNWIND nodes as n\n",
    "    MATCH (n)-[r:RELATED]-(m) \n",
    "    WHERE NOT m IN nodes\n",
    "    RETURN r.description AS descriptionText\n",
    "    ORDER BY r.rank, r.weight DESC \n",
    "    LIMIT $topOutsideRels\n",
    "} as outsideRels,\n",
    "// Inside Relationships \n",
    "collect {\n",
    "    UNWIND nodes as n\n",
    "    MATCH (n)-[r:RELATED]-(m) \n",
    "    WHERE m IN nodes\n",
    "    RETURN r.description AS descriptionText\n",
    "    ORDER BY r.rank, r.weight DESC \n",
    "    LIMIT $topInsideRels\n",
    "} as insideRels,\n",
    "// Entities description\n",
    "collect {\n",
    "    UNWIND nodes as n\n",
    "    RETURN n.description AS descriptionText\n",
    "} as entities\n",
    "// We don't have covariates or claims here\n",
    "RETURN {Chunks: text_mapping, Reports: report_mapping, \n",
    "       Relationships: outsideRels + insideRels, \n",
    "       Entities: entities} AS text, 1.0 AS score, {} AS metadata\n",
    "\"\"\"\n",
    "\n",
    "embeddings, dimension = load_embedding_model(\"sentence_transformer\")\n",
    "lc_vector = Neo4jVector.from_existing_index(\n",
    "    embeddings,\n",
    "    url=os.environ[\"NEO4J_URI\"],\n",
    "    username=os.environ[\"NEO4J_USERNAME\"],\n",
    "    password=os.environ[\"NEO4J_PASSWORD\"],\n",
    "    index_name=index_name,\n",
    "    retrieval_query=lc_retrieval_query,\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "docs = lc_vector.similarity_search_with_score(\n",
    "    \"Major cities of India\",\n",
    "    k=topEntities,\n",
    "    params={\n",
    "        \"topChunks\": topChunks,\n",
    "        \"topCommunities\": topCommunities,\n",
    "        \"topOutsideRels\": topOutsideRels,\n",
    "        \"topInsideRels\": topInsideRels,\n",
    "    },\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Entities:\n",
      "- None\n",
      "- None\n",
      "- None\n",
      "- One of the three biodiversity hotspots in India.\n",
      "- Officially the Republic of India, located in South Asia.\n",
      "- Geographical realm that includes India.\n",
      "- One of the three biodiversity hotspots in India.\n",
      "- Defines the northern frontiers of India.\n",
      "- One of the three biodiversity hotspots in India.\n",
      "- Commonly used name for the Republic of India.\n",
      "Reports:\n",
      "- India, officially the Republic of India, is a country located in South Asia and is part of the Indomalayan Realm. It shares borders with several countries including China, Bhutan, Nepal, Pakistan, Bangladesh, and Myanmar, and is bounded by the Indian Ocean, Arabian Sea, and Bay of Bengal. India is known for its rich biodiversity, featuring hotspots like the Western Ghats, Eastern Himalayas, and Indo-Burma Hotspot, and has a significant forest cover, which has been increasing as reported by the 2013 Forest Survey of India.\n",
      "\n",
      "India has a complex history, with ancient civilizations like the Indus Valley Civilisation and significant cultural contributions such as the Rigveda, which marks the dawn of Hinduism. It is also the birthplace of Buddhism and Jainism. The country has a diverse linguistic heritage, including the diffusion of the Indo-European language Sanskrit.\n",
      "\n",
      "Economically, India is a major global player, ranking as the fifth-largest economy by nominal GDP and third-largest by purchasing power parity (PPP). It has a significant public sector, a large labor force, and is a member of the World Trade Organization. The country has adopted broad economic liberalization since 1991, leading to substantial GDP growth and a robust service sector that makes up more than 50% of its GDP. India also has a high number of billionaires and is considered a welfare state with significant social welfare spending.\n",
      "\n",
      "Politically, India has been a federal republic since 1950, with the Indian National Congress historically dominating its politics until 1977. The Supreme Court of India heads its independent judiciary. The country has a rich legislative history concerning forest administration, with significant acts like the Indian Forest Act of 1865 and the Forest Act of 1878, and contributions from figures like Sir Dietrich Brandis, the Inspector General of Forests from 1864 to 1883.\n",
      "\n",
      "India's geographical and cultural landscape is further enriched by its rivers, such as the Ganges and Sindhu (Indus River), and its proximity to neighboring countries like Sri Lanka and the Maldives. The country is also part of the larger Indomalayan Realm and has historical ties to Africa, from where modern humans arrived on the Indian subcontinent.\n",
      "- India, officially the Republic of India, is a country located in South Asia and is part of the Indomalayan Realm. It shares borders with several countries including China, Bhutan, Nepal, Pakistan, Bangladesh, and Myanmar, and is bounded by the Indian Ocean, Arabian Sea, and Bay of Bengal. India is known for its rich biodiversity, featuring hotspots like the Western Ghats, Eastern Himalayas, and Indo-Burma Hotspot, and has a significant forest cover, which has been increasing as reported by the 2013 Forest Survey of India.\n",
      "\n",
      "India has a complex history, with ancient civilizations like the Indus Valley Civilisation and significant cultural contributions such as the Rigveda, which marks the dawn of Hinduism. It is also the birthplace of Buddhism and Jainism. The country has a diverse linguistic heritage, including the diffusion of the Indo-European language Sanskrit.\n",
      "\n",
      "Economically, India is a major global player, ranking as the fifth-largest economy by nominal GDP and third-largest by purchasing power parity (PPP). It has a significant public sector, a large labor force, and is a member of the World Trade Organization. The country has adopted broad economic liberalization since 1991, leading to substantial GDP growth and a robust service sector that makes up more than 50% of its GDP. India also has a high number of billionaires and is considered a welfare state with significant social welfare spending.\n",
      "\n",
      "Politically, India has been a federal republic since 1950, with the Indian National Congress historically dominating its politics until 1977. The Supreme Court of India heads its independent judiciary. The country has a rich legislative history concerning forest administration, with significant acts like the Indian Forest Act of 1865 and the Forest Act of 1878, and contributions from figures like Sir Dietrich Brandis, the Inspector General of Forests from 1864 to 1883.\n",
      "\n",
      "India's geographical and cultural landscape is further enriched by its rivers, such as the Ganges and Sindhu (Indus River), and its proximity to neighboring countries like Sri Lanka and the Maldives. The country is also part of the larger Indomalayan Realm and has historical ties to Africa, from where modern humans arrived on the Indian subcontinent.\n",
      "- India, officially the Republic of India, is a country located in South Asia and is part of the Indomalayan Realm. It shares borders with several countries including China, Bhutan, Nepal, Pakistan, Bangladesh, and Myanmar, and is bounded by the Indian Ocean, Arabian Sea, and Bay of Bengal. India is known for its rich biodiversity, featuring hotspots like the Western Ghats, Eastern Himalayas, and Indo-Burma Hotspot, and has a significant forest cover, which has been increasing as reported by the 2013 Forest Survey of India.\n",
      "\n",
      "India has a complex history, with ancient civilizations like the Indus Valley Civilisation and significant cultural contributions such as the Rigveda, which marks the dawn of Hinduism. It is also the birthplace of Buddhism and Jainism. The country has a diverse linguistic heritage, including the diffusion of the Indo-European language Sanskrit.\n",
      "\n",
      "Economically, India is a major global player, ranking as the fifth-largest economy by nominal GDP and third-largest by purchasing power parity (PPP). It has a significant public sector, a large labor force, and is a member of the World Trade Organization. The country has adopted broad economic liberalization since 1991, leading to substantial GDP growth and a robust service sector that makes up more than 50% of its GDP. India also has a high number of billionaires and is considered a welfare state with significant social welfare spending.\n",
      "\n",
      "Politically, India has been a federal republic since 1950, with the Indian National Congress historically dominating its politics until 1977. The Supreme Court of India heads its independent judiciary. The country has a rich legislative history concerning forest administration, with significant acts like the Indian Forest Act of 1865 and the Forest Act of 1878, and contributions from figures like Sir Dietrich Brandis, the Inspector General of Forests from 1864 to 1883.\n",
      "\n",
      "India's geographical and cultural landscape is further enriched by its rivers, such as the Ganges and Sindhu (Indus River), and its proximity to neighboring countries like Sri Lanka and the Maldives. The country is also part of the larger Indomalayan Realm and has historical ties to Africa, from where modern humans arrived on the Indian subcontinent.\n",
      "Chunks:\n",
      "- India is one of the most biodiverse regions and is home to a large variety of wildlife. It is one of the 17 megadiverse countries and includes three of the worlds 36 biodiversity hotspots – the Western Ghats, the Eastern Himalayas, and the Indo-Burma hotspot. About 24.6% of the total land area is covered by forests. It has various ecosystems ranging from the high altitude Himalayas, tropical evergreen forests along the Western Ghats, desert in the north-west, coastal plains and mangroves along the peninsular region. India lies within the Indomalayan realm and is home to about 7.6% of mammal, 14.7% of amphibian, 6% of bird, 6.2% of reptilian, and 6.2% of flowering plant species. Human encroachment, deforestation and poaching are significant challenges that threaten the existence of certain fauna and flora. Government of India established a system of national parks and\n",
      "-  threaten the existence of certain fauna and flora. Government of India established a system of national parks and protected areas in 1935, which have been subsequently expanded to nearly 1022 protected areas by 2023. India has enacted the Wildlife Protection Act of 1972 and special projects such as Project Tiger, Project Elephant and Project Dolphin for protection of critical species.   == Fauna ==  India has an estimated 92,873 species of fauna, roughly about 7.5% of the species available worldwide. Insects form the major category with 63423 recorded species. India is home to 423 mammals, 1233 birds, 526 reptiles, 342 amphibians, 3022 fish apart from other species which form 7.6% of mammal, 14.7% of amphibian, 6% of bird, 6.2% of reptilian species worldwide. Many Indian species are descendants of species originating in Gondwana, of which India originally was a part. Peninsular Indias subsequent movement towards\n",
      "-  Gondwana, of which India originally was a part. Peninsular Indias subsequent movement towards, and collision with, the Laurasian landmass set off a mass exchange of species. However, volcanism in the Deccan Traps and climatic change 20 million years ago caused the extinction of many endemic Indian forms. Soon thereafter, mammals entered India from Asia through two zoogeographical passes on either side of the emerging Himalayas. As a result, among Indian species, only 12.6% of mammals and 4.5% of birds are endemic, contrasting with 45.8% of reptiles and 55.8% of amphibians  India is home to several well-known large animals, including the Indian elephant, Indian rhinoceros, and Gaur. India is the only country where the big cats tiger and lion exist in the wild. Members of the cat family include Bengal tiger, Asiatic lion, Indian leopard, snow leopard, and clouded\n",
      "Relationships:\n",
      "\n"
     ]
    }
   ],
   "source": [
    "print(docs[0][0].page_content)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "model = \"openai-gpt-4o\"\n",
    "llm, model_name = get_llm(model)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "MAP_SYSTEM_PROMPT = \"\"\"\n",
    "---Role---\n",
    "\n",
    "You are a helpful assistant responding to questions about data in the tables provided.\n",
    "\n",
    "\n",
    "---Goal---\n",
    "\n",
    "Generate a response consisting of a list of key points that responds to the user's question, summarizing all relevant information in the input data tables.\n",
    "\n",
    "You should use the data provided in the data tables below as the primary context for generating the response.\n",
    "If you don't know the answer or if the input data tables do not contain sufficient information to provide an answer, just say so. Do not make anything up.\n",
    "\n",
    "Each key point in the response should have the following element:\n",
    "- Description: A comprehensive description of the point.\n",
    "- Importance Score: An integer score between 0-100 that indicates how important the point is in answering the user's question. An 'I don't know' type of response should have a score of 0.\n",
    "\n",
    "The response should be JSON formatted as follows:\n",
    "{{\n",
    "    \"points\": [\n",
    "        {{\"description\": \"Description of point 1 [Data: Reports (report ids)]\", \"score\": score_value}},\n",
    "        {{\"description\": \"Description of point 2 [Data: Reports (report ids)]\", \"score\": score_value}}\n",
    "    ]\n",
    "}}\n",
    "\n",
    "The response shall preserve the original meaning and use of modal verbs such as \"shall\", \"may\" or \"will\".\n",
    "\n",
    "Points supported by data should list the relevant reports as references as follows:\n",
    "\"This is an example sentence supported by data references [Data: Reports (report ids)]\"\n",
    "\n",
    "**Do not list more than 5 record ids in a single reference**. Instead, list the top 5 most relevant record ids and add \"+more\" to indicate that there are more.\n",
    "\n",
    "For example:\n",
    "\"Person X is the owner of Company Y and subject to many allegations of wrongdoing [Data: Reports (2, 7, 64, 46, 34, +more)]. He is also CEO of company X [Data: Reports (1, 3)]\"\n",
    "\n",
    "where 1, 2, 3, 7, 34, 46, and 64 represent the id (not the index) of the relevant data report in the provided tables.\n",
    "\n",
    "Do not include information where the supporting evidence for it is not provided.\n",
    "\n",
    "\n",
    "---Data tables---\n",
    "\n",
    "{context_data}\n",
    "\n",
    "---Goal---\n",
    "\n",
    "Generate a response consisting of a list of key points that responds to the user's question, summarizing all relevant information in the input data tables.\n",
    "\n",
    "You should use the data provided in the data tables below as the primary context for generating the response.\n",
    "If you don't know the answer or if the input data tables do not contain sufficient information to provide an answer, just say so. Do not make anything up.\n",
    "\n",
    "Each key point in the response should have the following element:\n",
    "- Description: A comprehensive description of the point.\n",
    "- Importance Score: An integer score between 0-100 that indicates how important the point is in answering the user's question. An 'I don't know' type of response should have a score of 0.\n",
    "\n",
    "The response shall preserve the original meaning and use of modal verbs such as \"shall\", \"may\" or \"will\".\n",
    "\n",
    "Points supported by data should list the relevant reports as references as follows:\n",
    "\"This is an example sentence supported by data references [Data: Reports (report ids)]\"\n",
    "\n",
    "**Do not list more than 5 record ids in a single reference**. Instead, list the top 5 most relevant record ids and add \"+more\" to indicate that there are more.\n",
    "\n",
    "For example:\n",
    "\"Person X is the owner of Company Y and subject to many allegations of wrongdoing [Data: Reports (2, 7, 64, 46, 34, +more)]. He is also CEO of company X [Data: Reports (1, 3)]\"\n",
    "\n",
    "where 1, 2, 3, 7, 34, 46, and 64 represent the id (not the index) of the relevant data report in the provided tables.\n",
    "\n",
    "Do not include information where the supporting evidence for it is not provided.\n",
    "\n",
    "The response should be JSON formatted as follows:\n",
    "{{\n",
    "    \"points\": [\n",
    "        {{\"description\": \"Description of point 1 [Data: Reports (report ids)]\", \"score\": score_value}},\n",
    "        {{\"description\": \"Description of point 2 [Data: Reports (report ids)]\", \"score\": score_value}}\n",
    "    ]\n",
    "}}\n",
    "\"\"\"\n",
    "\n",
    "map_prompt = ChatPromptTemplate.from_messages(\n",
    "    [\n",
    "        (\n",
    "            \"system\",\n",
    "            MAP_SYSTEM_PROMPT,\n",
    "        ),\n",
    "        (\n",
    "            \"human\",\n",
    "            \"{question}\",\n",
    "        ),\n",
    "    ]\n",
    ")\n",
    "\n",
    "map_chain = map_prompt | llm | StrOutputParser()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "REDUCE_SYSTEM_PROMPT = \"\"\"\n",
    "---Role---\n",
    "\n",
    "You are a helpful assistant responding to questions about a dataset by synthesizing perspectives from multiple analysts.\n",
    "\n",
    "\n",
    "---Goal---\n",
    "\n",
    "Generate a response of the target length and format that responds to the user's question, summarize all the reports from multiple analysts who focused on different parts of the dataset.\n",
    "\n",
    "Note that the analysts' reports provided below are ranked in the **descending order of importance**.\n",
    "\n",
    "If you don't know the answer or if the provided reports do not contain sufficient information to provide an answer, just say so. Do not make anything up.\n",
    "\n",
    "The final response should remove all irrelevant information from the analysts' reports and merge the cleaned information into a comprehensive answer that provides explanations of all the key points and implications appropriate for the response length and format.\n",
    "\n",
    "Add sections and commentary to the response as appropriate for the length and format. Style the response in markdown.\n",
    "\n",
    "The response shall preserve the original meaning and use of modal verbs such as \"shall\", \"may\" or \"will\".\n",
    "\n",
    "The response should also preserve all the data references previously included in the analysts' reports, but do not mention the roles of multiple analysts in the analysis process.\n",
    "\n",
    "**Do not list more than 5 record ids in a single reference**. Instead, list the top 5 most relevant record ids and add \"+more\" to indicate that there are more.\n",
    "\n",
    "For example:\n",
    "\n",
    "\"Person X is the owner of Company Y and subject to many allegations of wrongdoing [Data: Reports (2, 7, 34, 46, 64, +more)]. He is also CEO of company X [Data: Reports (1, 3)]\"\n",
    "\n",
    "where 1, 2, 3, 7, 34, 46, and 64 represent the id (not the index) of the relevant data record.\n",
    "\n",
    "Do not include information where the supporting evidence for it is not provided.\n",
    "\n",
    "\n",
    "---Target response length and format---\n",
    "\n",
    "{response_type}\n",
    "\n",
    "\n",
    "---Analyst Reports---\n",
    "\n",
    "{report_data}\n",
    "\n",
    "\n",
    "---Goal---\n",
    "\n",
    "Generate a response of the target length and format that responds to the user's question, summarize all the reports from multiple analysts who focused on different parts of the dataset.\n",
    "\n",
    "Note that the analysts' reports provided below are ranked in the **descending order of importance**.\n",
    "\n",
    "If you don't know the answer or if the provided reports do not contain sufficient information to provide an answer, just say so. Do not make anything up.\n",
    "\n",
    "The final response should remove all irrelevant information from the analysts' reports and merge the cleaned information into a comprehensive answer that provides explanations of all the key points and implications appropriate for the response length and format.\n",
    "\n",
    "The response shall preserve the original meaning and use of modal verbs such as \"shall\", \"may\" or \"will\".\n",
    "\n",
    "The response should also preserve all the data references previously included in the analysts' reports, but do not mention the roles of multiple analysts in the analysis process.\n",
    "\n",
    "**Do not list more than 5 record ids in a single reference**. Instead, list the top 5 most relevant record ids and add \"+more\" to indicate that there are more.\n",
    "\n",
    "For example:\n",
    "\n",
    "\"Person X is the owner of Company Y and subject to many allegations of wrongdoing [Data: Reports (2, 7, 34, 46, 64, +more)]. He is also CEO of company X [Data: Reports (1, 3)]\"\n",
    "\n",
    "where 1, 2, 3, 7, 34, 46, and 64 represent the id (not the index) of the relevant data record.\n",
    "\n",
    "Do not include information where the supporting evidence for it is not provided.\n",
    "\n",
    "\n",
    "---Target response length and format---\n",
    "\n",
    "{response_type}\n",
    "\n",
    "Add sections and commentary to the response as appropriate for the length and format. Style the response in markdown.\n",
    "\"\"\"\n",
    "\n",
    "reduce_prompt = ChatPromptTemplate.from_messages(\n",
    "    [\n",
    "        (\n",
    "            \"system\",\n",
    "            REDUCE_SYSTEM_PROMPT,\n",
    "        ),\n",
    "        (\n",
    "            \"human\",\n",
    "            \"{question}\",\n",
    "        ),\n",
    "    ]\n",
    ")\n",
    "reduce_chain = reduce_prompt | llm | StrOutputParser()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "graph = Neo4jGraph(\n",
    "    url=os.environ[\"NEO4J_URI\"],\n",
    "    username=os.environ[\"NEO4J_USERNAME\"],\n",
    "    password=os.environ[\"NEO4J_PASSWORD\"],\n",
    "    refresh_schema=False,\n",
    ")\n",
    "\n",
    "response_type: str = \"multiple paragraphs\"\n",
    "\n",
    "\n",
    "def global_retriever(query: str, level: int, response_type: str = response_type) -> str:\n",
    "    community_data = graph.query(\n",
    "        \"\"\"\n",
    "    MATCH (c:__Community__)\n",
    "    WHERE c.level = $level\n",
    "    RETURN c.full_content AS output\n",
    "    \"\"\",\n",
    "        params={\"level\": level},\n",
    "    )\n",
    "    intermediate_results = []\n",
    "    for community in tqdm(community_data, desc=\"Processing communities\"):\n",
    "        intermediate_response = map_chain.invoke(\n",
    "            {\"question\": query, \"context_data\": community[\"output\"]}\n",
    "        )\n",
    "        intermediate_results.append(intermediate_response)\n",
    "    final_response = reduce_chain.invoke(\n",
    "        {\n",
    "            \"report_data\": intermediate_results,\n",
    "            \"question\": query,\n",
    "            \"response_type\": response_type,\n",
    "        }\n",
    "    )\n",
    "    return final_response"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "WARNING:neo4j.notifications:Received notification from DBMS server: {severity: WARNING} {code: Neo.ClientNotification.Statement.UnknownPropertyKeyWarning} {category: UNRECOGNIZED} {title: The provided property key is not in the database} {description: One of the property names in your query is not available in the database, make sure you didn't misspell it or that the label is available when you run this statement in your application (the missing property name is: full_content)} {position: line: 4, column: 14, offset: 69} for query: '\\n    MATCH (c:__Community__)\\n    WHERE c.level = $level\\n    RETURN c.full_content AS output\\n    '\n",
      "Processing communities: 0it [00:00, ?it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "I'm sorry, but the provided reports do not contain sufficient information to provide an answer to your question about the major cities of India. If you have any other questions or need information on a different topic, please let me know!\n"
     ]
    }
   ],
   "source": [
    "print(global_retriever(\"Major cities of India?\", 2))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "chatbotenv",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
